WebSecurity ResetPassword 方法

websecurity - resetpassword()

websecurity 對(duì)象 websecurity 對(duì)象

定義

resetpassword() 方法使用密碼令牌重置用戶密碼。

c# 和 vb 語(yǔ)法

websecurity.resetpassword(passwordresettoken,newpassword)

參數(shù)

參數(shù) 類(lèi)型 描述
passwordresettoken string 密碼令牌
newpassword string 新密碼

返回值

類(lèi)型 描述
boolean 如果密碼已更改,則返回 true,否則返回 false。

錯(cuò)誤和異常

在下面的情況下,任何對(duì) websecurity 對(duì)象的訪問(wèn)將拋出一個(gè) invalidoperationexception:

  • initializedatabaseconnection() 方法沒(méi)有被調(diào)用
  • simplemembership 沒(méi)有初始化(或者在網(wǎng)站配置中禁用)

備注

如果用戶已忘記密碼,請(qǐng)使用 resetpassword 方法。

resetpassword 方法要求一個(gè)密碼重置令牌。

確認(rèn)令牌可通過(guò) createaccount()、 createuserandaccount() 或 generatepasswordresettoken() 方法創(chuàng)建。

密碼可通過(guò)代碼重置,但是一般過(guò)程是發(fā)送電子郵件給用戶(帶有令牌和指向頁(yè)面的鏈接),這樣用戶就可以通過(guò)新的令牌確認(rèn)新的密碼:

@{
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>

技術(shù)數(shù)據(jù)

名稱
namespace webmatrix.webdata
assembly webmatrix.webdata.dll

websecurity 對(duì)象 websecurity 對(duì)象
相關(guān)文章
亚洲国产精品第一区二区,久久免费视频77,99V久久综合狠狠综合久久,国产免费久久九九免费视频