Skip to content

Commit

Permalink
do not show success message if email does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
creme332 committed Apr 24, 2024
1 parent 8fcb843 commit 14e7109
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/controllers/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ private function handleEmailSubmission(): void
{
$submitted_email = filter_var($_POST['email'] ?? "", FILTER_VALIDATE_EMAIL);

// check if email has a valid format
if (empty($submitted_email)) {
$this->view_data['error'] = 'Invalid email';
return;
}
// email is valid

// get user ID corresponding to user email
$userId = User::getUserIdByEmail($submitted_email);
Expand All @@ -76,7 +76,13 @@ private function handleEmailSubmission(): void
// Send email to user with password reset link and user id
$passwordResetLink = ROOT . "/password/reset?token=" . $token_info['token'] .
"&id=" . $token_info['request_id'];
$this->sendResetEmail($submitted_email, $passwordResetLink);

try {
$this->sendResetEmail($submitted_email, $passwordResetLink);
$this->view_data['email_submit_success'] = true;
} catch (Exception) {
return;
}
}

/**
Expand Down Expand Up @@ -150,7 +156,6 @@ public function index(): void
// user has submitted his email
try {
$this->handleEmailSubmission();
$this->view_data['email_submit_success'] = true;
} catch (Exception) {
$this->view_data['error'] = 'Mailing service is not operational. Please try again later.';
}
Expand Down

0 comments on commit 14e7109

Please sign in to comment.