Пример #1
0
        public async Task <IActionResult> ConfirmReset(string userId, string token, string newPass)
        {
            //to-do proper error handling required
            //if (userId == null || code == null)
            //{
            //    return RedirectToAction(nameof(HomeController.Index), "Home");
            //}
            try
            {
                var user = await _userManager.FindByIdAsync(userId);

                if (user == null)
                {
                    throw new ApplicationException($"Unable to load user with ID '{userId}'.");
                }

                var result = await _userManager.ResetPasswordAsync(user, token, newPass);

                if (result.Succeeded)
                {
                    var strHomeUrl  = _config["ReturnURL"];
                    var strRedirect = new Uri(strHomeUrl).ToString();
                    var strMessage  = EmailTemplates.GetResetConfirmationMessage(strRedirect);
                    return(Content(strMessage, "text/html"));
                }

                //else
                //    throw new ApplicationException($"Unable to confirm email for user with ID '{userId}'.");
                return(Ok()); //???
            }
            catch (Exception ex)
            {
                var s = ex.Message;
            }

            return(Ok()); //???
        }