mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-11 14:10:06 +01:00
feat: new recovery code generation finally
This commit is contained in:
parent
30674acb07
commit
ec72b6937e
2 changed files with 14 additions and 6 deletions
|
@ -30,6 +30,17 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
} else {
|
||||
$error = 'Your old password is incorrect.';
|
||||
}
|
||||
} else if (isset($_POST['reset_recovery_code'])) {
|
||||
if (pp_password_verify($_POST['old_password'], $user_password)) {
|
||||
$user_new_code = pp_random_token();
|
||||
|
||||
$current_user->recovery_code_hash = pp_password_hash($user_new_code);
|
||||
$current_user->save();
|
||||
|
||||
$success = 'Your recovery code has been updated - please see below.';
|
||||
} else {
|
||||
$error = 'Your password is incorrect.';
|
||||
}
|
||||
} else {
|
||||
$error = 'All fields must be filled out.';
|
||||
}
|
||||
|
|
|
@ -28,18 +28,15 @@
|
|||
<div class="field">
|
||||
<label class="label">Generate New Recovery Key</label>
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input disabled="" type="text" class="input" name="username"
|
||||
style="cursor:not-allowed;" placeholder="New key generated here">
|
||||
<input disabled="disabled" type="text" class="input"
|
||||
style="cursor:not-allowed;" placeholder="New key generated here" value="<?= isset($user_new_code) ? pp_html_escape($user_new_code) : '' ?>">
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-user"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<button disabled type="submit" name="Gen_key" class="button is-info">Generate New Key
|
||||
</button>
|
||||
<br>
|
||||
<small>Coming soon</small>
|
||||
<button disabled type="submit" name="reset_recovery_code" class="button is-info">Generate new key</button>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="field">
|
||||
|
|
Loading…
Add table
Reference in a new issue