वेब सुरक्षा - पासवर्ड रीसेट करें ()
❮ वेब सुरक्षा
परिभाषा
रीसेटपासवर्ड () विधि पासवर्ड टोकन का उपयोग करके उपयोगकर्ता पासवर्ड को रीसेट करती है।
सी # और वीबी सिंटेक्स
WebSecurity.ResetPassword(passwordResetToken,newPassword)
मापदंडों
Parameter | Type | Description |
---|---|---|
passwordResetToken | String | The password token |
newpassword | String | The new password |
प्रतिलाभ की मात्रा
Type | Description |
---|---|
Boolean | true if the password was changed, otherwise false |
त्रुटियाँ और अपवाद
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>
❮ वेब सुरक्षा