WebSecurity - Parolayı Sıfırla ()
❮ Web Güvenliği
Tanım
ResetPassword () yöntemi, bir parola belirteci kullanarak bir kullanıcı parolasını sıfırlar.
C# ve VB Sözdizimi
WebSecurity.ResetPassword(passwordResetToken,newPassword)
parametreler
Parameter | Type | Description |
---|---|---|
passwordResetToken | String | The password token |
newpassword | String | The new password |
Geri dönüş değeri
Type | Description |
---|---|
Boolean | true if the password was changed, otherwise false |
Hatalar ve İstisnalar
WebSecurity nesnesine herhangi bir erişim, aşağıdaki durumlarda bir InvalidOperationException oluşturur :
- InitializeDatabaseConnection() yöntemi çağrılmadı
- SimpleMembership başlatılmadı (veya web sitesi yapılandırmasında devre dışı bırakıldı)
Notlar
Kullanıcı parolasını unuttuysa ResetPassword yöntemini kullanın .
ResetPassword yöntemi, bir parola sıfırlama belirteci gerektirir .
CreateAccount() , CreateUserAndAccount() veya GeneratePasswordResetToken() yöntemleri tarafından bir onay belirteci oluşturulabilir .
Parola kodla sıfırlanabilir, ancak genel prosedür, kullanıcıya yeni parolayı yeni simgeyle onaylayabilmesi için (belirteç ve bir sayfa bağlantısıyla birlikte) bir e-posta göndermektir:
@{
newPassword = Request["newPassword"];
confirmPassword = Request["confirmPassword"];
token = Request["token"];
if IsPost
{
// input testing is ommitted here to save space
retunValue = ResetPassword(token, newPassword);
}
}
<h1>Change Password</h1>
<form method="post" action="">
<label for="newPassword">New Password:</label>
<input type="password"
id="newPassword" name="newPassword" title="New password" />
<label
for="confirmPassword">Confirm Password:</label>
<input type="password"
id="confirmPassword" name="confirmPassword" title="Confirm new password" />
<label for="token">Pasword Token:</label>
<input type="text"
id="token" name="token" title="Password Token" />
<p
class="form-actions">
<input type="submit" value="Change Password"
title="Change password" />
</p>
</form>
❮ Web Güvenliği