Ejemplo n.º 1
0
        public async Task <ApplicationUser> ValidateUser(UserValidatorJson userJson)
        {
            string email    = userJson.email;
            string password = userJson.password;

            ApplicationUser user = await _context.Users
                                   .Include(r => r.Recipes)
                                   .Include(r => r.LikesDislikes)
                                   .Include(r => r.Comments)
                                   .Include(r => r.SavedRecipes)
                                   .Include(r => r.UsersGroups)
                                   .ThenInclude(rG => rG.Group)
                                   .Where(r => r.Email == email)
                                   .FirstOrDefaultAsync();

            string hashedPassword = user.PasswordHash;

            if (_userManager.PasswordHasher.VerifyHashedPassword(user, user.PasswordHash, userJson.password)
                != PasswordVerificationResult.Failed)
            {
                return(user);
            }

            return(new ApplicationUser());
        }
Ejemplo n.º 2
0
        public async Task <ApplicationUser> ValidateUser([FromBody] UserValidatorJson userJson)
        {
            ApplicationUser user = await _usersService.ValidateUser(userJson);

            return(user);
        }