Пример #1
0
        private void CreateUser(RegistrationViewModel registrationViewModel)
        {
            var user = _membershipService.CreateUser(registrationViewModel.Email, registrationViewModel.Password);

            _userResourcesService.AddUserResources(user);
            _sendEmailService.Send(user.Email, GetConfirmLink(user.Email, user.ConfirmCode));
            _appHub.Clients.All.addUser(Mapper.Map <UserViewModel>(user));
        }
        public async Task <IActionResult> ResetPassword(ResetPasswordModel reset)
        {
            if (ModelState.IsValid)
            {
                var user = await userManager.FindByEmailAsync(reset.Email);

                if (user != null)
                {
                    var code = await userManager.GeneratePasswordResetTokenAsync(user);

                    var    callbackUrl = MakeAction(nameof(ResetPasswordCode), "Profile", new { userId = user.Id, code = code });
                    string emailBody   = await viewRender.RenderToStringAsync("Templates/ResetPasswordLetterBody", callbackUrl);

                    sendEmail.Send(new EmailLetter {
                        To = reset.Email, Subject = "Восстановление пароля", Body = emailBody
                    });
                }

                return(RedirectToAction(nameof(ResetPasswordSendOk)));
            }

            return(View());
        }