वेब सुरक्षा - GeneratePasswordResetToken ()
❮ वेब सुरक्षा
परिभाषा
GeneratePasswordResetToken () विधि एक पासवर्ड रीसेट टोकन उत्पन्न करती है जिसे ईमेल में उपयोगकर्ता को भेजा जा सकता है।
सी # और वीबी सिंटेक्स
WebSecurity.GeneratePasswordResetToken(userName, expiration)
मापदंडों
Parameter | Type | Description |
---|---|---|
userName | String | The user name |
expiration | Integer | The time in minutes until the token expires. Default is 1440 (24 hours) |
प्रतिलाभ की मात्रा
Type | Description |
---|---|
String | A reset token. |
त्रुटियाँ और अपवाद
WebSecurity ऑब्जेक्ट के लिए कोई भी एक्सेस एक InvalidOperationException फेंकता है यदि:
- InitializeDatabaseConnection () विधि को नहीं कहा गया है
- SimpleMembership प्रारंभ नहीं किया गया है (या वेबसाइट कॉन्फ़िगरेशन में अक्षम है)
टिप्पणियां
यदि उपयोगकर्ता अपना पासवर्ड भूल गया है, तो रीसेटपासवर्ड () विधि का उपयोग करें । ResetPassword() विधि के लिए पासवर्ड रीसेट टोकन की आवश्यकता होती है ।
एक पुष्टिकरण टोकन CreateAccount() , CreateUserAndAccount() , या GeneratePasswordResetToken() विधियों द्वारा बनाया जा सकता है ।
पासवर्ड को कोड द्वारा रीसेट किया जा सकता है, लेकिन सामान्य प्रक्रिया उपयोगकर्ता को एक ईमेल भेजना है (टोकन और एक पृष्ठ के लिंक के साथ) ताकि वह नए टोकन के साथ नए पासवर्ड की पुष्टि कर सके:
@{
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>
❮ वेब सुरक्षा