From ec72b6937ee318f944405e13a2d3b7b3f6d5ffa0 Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Fri, 14 Jul 2023 11:30:35 -0400 Subject: [PATCH] feat: new recovery code generation finally --- public/profile.php | 11 +++++++++++ theme/bulma/profile.php | 9 +++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/public/profile.php b/public/profile.php index 68d7b83..d765a24 100644 --- a/public/profile.php +++ b/public/profile.php @@ -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.'; } diff --git a/theme/bulma/profile.php b/theme/bulma/profile.php index 873a7bf..110ba06 100644 --- a/theme/bulma/profile.php +++ b/theme/bulma/profile.php @@ -28,18 +28,15 @@