Ejemplo n.º 1
0
        public async Task <OperationResult> ChangeEmail(string userId, string email, string password)
        {
            User user = await userManager.FindByIdAsync(userId);

            if (!await userManager.CheckPasswordAsync(user, password))
            {
                return(OperationResult.Invalid("Invalid password"));
            }

            if (user.Email == email)
            {
                return(OperationResult.Invalid("The new e-mail address cannot be the same as your current e-mail."));
            }

            await emailConfirmationService.ProcessEmailChange(user, email);

            return(OperationResult.Valid());
        }