mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 06:30:07 +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 {
|
} else {
|
||||||
$error = 'Your old password is incorrect.';
|
$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 {
|
} else {
|
||||||
$error = 'All fields must be filled out.';
|
$error = 'All fields must be filled out.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,18 +28,15 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Generate New Recovery Key</label>
|
<label class="label">Generate New Recovery Key</label>
|
||||||
<div class="control has-icons-left has-icons-right">
|
<div class="control has-icons-left has-icons-right">
|
||||||
<input disabled="" type="text" class="input" name="username"
|
<input disabled="disabled" type="text" class="input"
|
||||||
style="cursor:not-allowed;" placeholder="New key generated here">
|
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">
|
<span class="icon is-small is-left">
|
||||||
<i class="fas fa-user"></i>
|
<i class="fas fa-user"></i>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<button disabled type="submit" name="Gen_key" class="button is-info">Generate New Key
|
<button disabled type="submit" name="reset_recovery_code" class="button is-info">Generate new key</button>
|
||||||
</button>
|
|
||||||
<br>
|
|
||||||
<small>Coming soon</small>
|
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|
Loading…
Add table
Reference in a new issue