WebSecurity - GeneratePasswordResetToken()
❮ Web Güvenliği
Tanım
GeneratePasswordResetToken() yöntemi , bir kullanıcıya e-postayla gönderilebilecek bir parola sıfırlama belirteci oluşturur.
C# ve VB Sözdizimi
WebSecurity.GeneratePasswordResetToken(userName, expiration)
parametreler
Parameter | Type | Description |
---|---|---|
userName | String | The user name |
expiration | Integer | The time in minutes until the token expires. Default is 1440 (24 hours) |
Geri dönüş değeri
Type | Description |
---|---|
String | A reset token. |
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