Пример #1
0
        protected void Reset_Click(object sender, EventArgs e)
        {
            string code = IdentityHelpers.GetCodeFromRequest(Request);

            if (code != null)
            {
                var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();

                var user = manager.FindByEmail(Email.Text);
                if (user == null)
                {
                    ErrorMessage.Text = "No user found";
                    return;
                }
                var result = manager.ResetPassword(user.Id, code, Password.Text);
                if (result.Succeeded)
                {
                    Response.Redirect("~/Account/ResetPasswordConfirmation.aspx");
                    return;
                }
                ErrorMessage.Text = result.Errors.FirstOrDefault();
                return;
            }

            ErrorMessage.Text = "An error has occurred";
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string code   = IdentityHelpers.GetCodeFromRequest(Request);
            string userId = IdentityHelpers.GetUserIdFromRequest(Request);

            if (code != null && userId != null)
            {
                var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                var result  = manager.ConfirmEmail(userId, code);
                if (result.Succeeded)
                {
                    successPanel.Visible = true;
                    return;
                }
            }
            successPanel.Visible = false;
            errorPanel.Visible   = true;
        }