Update 07082021
This commit is contained in:
46
WebFormApp/Account/ResetPassword.aspx.cs
Normal file
46
WebFormApp/Account/ResetPassword.aspx.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Identity.Owin;
|
||||
using Owin;
|
||||
using WebFormApp.Models;
|
||||
|
||||
namespace WebFormApp.Account
|
||||
{
|
||||
public partial class ResetPassword : Page
|
||||
{
|
||||
protected string StatusMessage
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
protected void Reset_Click(object sender, EventArgs e)
|
||||
{
|
||||
string code = IdentityHelper.GetCodeFromRequest(Request);
|
||||
if (code != null)
|
||||
{
|
||||
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
|
||||
|
||||
var user = manager.FindByName(Email.Text);
|
||||
if (user == null)
|
||||
{
|
||||
ErrorMessage.Text = "Es wurde kein Benutzer gefunden.";
|
||||
return;
|
||||
}
|
||||
var result = manager.ResetPassword(user.Id, code, Password.Text);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
Response.Redirect("~/Account/ResetPasswordConfirmation");
|
||||
return;
|
||||
}
|
||||
ErrorMessage.Text = result.Errors.FirstOrDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorMessage.Text = "Fehler";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user