示例#1
0
        private async Task <ClaimsIdentity> GetClaimsIdentityAdmin(string userName, string password)
        {
            userName = "******";
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                return(await Task.FromResult <ClaimsIdentity>(null));
            }

            // get the user to verifty
            var userToVerify = await _userManager.FindByNameAsync(userName);

            if (userToVerify == null)
            {
                return(await Task.FromResult <ClaimsIdentity>(null));
            }

            // check the credentials
            if (await _userManager.CheckPasswordAsync(userToVerify, password))
            {
                return(await Task.FromResult(_jwtFactory.GenerateClaimsIdentityAdmin(userName, userToVerify.Id)));
            }

            // Credentials are invalid, or account doesn't exist
            return(await Task.FromResult <ClaimsIdentity>(null));
        }