Exemplo n.º 1
0
        public async Task <ActionResult> ResetPassword(Models.Profile.ResetPasswordViewModel model)
        {
            var profile = await _profileSuperAdminService.GetProfileByProfileIdAsync(model.Id);

            if (!ModelState.IsValid)
            {
                ViewBag.Title = $"Reset password for {profile.FirstName} {profile.LastName}";
                return(View(model));
            }
            var user = await UserManager.FindByEmailAsync(profile.Email);

            if (user == null)
            {
                return(RedirectToAction("ResetPassword", "Profile", new { profileId = model.Id, role = model.Role }));
            }
            var code = await UserManager.GeneratePasswordResetTokenAsync(profile.UserId);

            var result = await UserManager.ResetPasswordAsync(user.Id, code, model.Password);

            if (result.Succeeded)
            {
                return(RedirectToAction("Index", "Profile", new { roleName = model.Role }));
            }
            AddErrors(result);
            ViewBag.Title = $"Reset password for {profile.FirstName} {profile.LastName}";
            return(View());
        }
Exemplo n.º 2
0
        public async Task <ActionResult> ResetPassword(Guid profileId, string role)
        {
            var profile = await _profileSuperAdminService.GetProfileByProfileIdAsync(profileId);

            var model = new Models.Profile.ResetPasswordViewModel
            {
                Id   = profileId,
                Role = role
            };

            ViewBag.Title = $"Reset password for {profile.FirstName} {profile.LastName}";
            return(View(model));
        }