WebSecurity - 비밀번호 재설정()


❮ 웹보안

정의

ResetPassword() 메서드 는 암호 토큰을 사용하여 사용자 암호를 재설정합니다.


C# 및 VB 구문

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 메소드를 사용하십시오 .

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>

❮ 웹보안