예제 #1
0
        public Result ForgotPassword(AdminForgotPasswordDto dto, out AdminUser adminUser)
        {
            adminUser = null;

            var validator = new AdminForgotPasswordValidator();
            var result    = validator.ValidateResult(dto);

            if (!result.Success)
            {
                return(result);
            }

            result = ForgotPasswordResponse(dto.Email);

            adminUser = _adminUserRepository.AsNoTracking
                        .FirstOrDefault(w => w.IsActive && w.Email == dto.Email);

            if (adminUser != null)
            {
                adminUser = new AdminUser()
                {
                    Name  = adminUser.Name,
                    Email = adminUser.Email,
                    ForgotPasswordToken = GenerateAndSaveForgotPasswordToken(adminUser)
                };
            }

            return(result);
        }
예제 #2
0
        public JsonResult ForgotPassword(AdminForgotPasswordDto dto)
        {
            var result = _adminForgotPasswordService.ForgotPassword(dto, out var adminUser);

            if (adminUser != null)
            {
                new EmailService(_emailTemplateService, _appSettings).SendAdminForgotPasswordEmail(adminUser);
            }

            if (result.Success)
            {
                result.Clear();
            }
            return(ToJsonResult(result));
        }