Esempio n. 1
0
        private async Task <ClaimsIdentity> GetClaimsIdentity(string email, string password)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                return(await Task.FromResult <ClaimsIdentity>(null));
            }

            // get the user to verifty
            var userToVerify = await _userManager.FindByEmailAsync(email);

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

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

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