Skip to content

Commit

Permalink
fix case of non existant user_id in session
Browse files Browse the repository at this point in the history
  • Loading branch information
DidierViret committed Jun 28, 2024
1 parent 1e6acdb commit 8d46d16
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions orif/user/Controllers/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ public function initController(RequestInterface $request,
public function change_password(): Response|string|RedirectResponse {

// Get user from DB, redirect if user doesn't exist
$user = $this->user_model->withDeleted()->find($_SESSION['user_id']);
if (is_null($user)) return redirect()->to('/user/auth/login');
if(isset($_SESSION['user_id'])) {
$user = $this->user_model->withDeleted()->find($_SESSION['user_id']);
if (is_null($user)) return redirect()->to('/user/auth/login');
} else {
return redirect()->to('/user/auth/login');
}

// Empty errors message in output
$output['errors'] = [];
Expand Down Expand Up @@ -91,7 +95,6 @@ public function change_password(): Response|string|RedirectResponse {
$_SESSION['reset_password'] = $user['reset_password'];
$output['title'] = lang('user_lang.page_my_password_change');
return $this->display_view('\User\auth\change_password', $output);

}
}
?>

0 comments on commit 8d46d16

Please sign in to comment.