Skip to content

Commit

Permalink
Correct redirect after validation code verification
Browse files Browse the repository at this point in the history
  • Loading branch information
DidierViret committed Jun 28, 2024
1 parent f377fcc commit 738c695
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions orif/user/Controllers/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ public function verify_verification_code() {
$this->user_model->update($ci_user['id'], $data);

$_SESSION['logged_in'] = (bool)true;

// Send the user to the redirection URL
return redirect()->to($_SESSION['after_login_redirect']);
}

} else { // Code is not valid for any reason (false and/or expired)
Expand Down
9 changes: 9 additions & 0 deletions tests/orif/user/Controllers/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,22 @@ public function test_azure_mail_with_correct_code_existing_user(): void
$_SESSION['new_user'] = false;
$_SESSION['azure_mail'] = "[email protected]";
$_SESSION['form_email'] = "[email protected]";
$redirect_url = $_SESSION['after_login_redirect'];

$result = $this->controller(Auth::class)
->execute('verify_verification_code');

/* Check that user's azure_mail has been updated in the DB */
$azureMailInDb = $userModel->select('azure_mail')
->find($userId)['azure_mail'];
$this->assertEquals($_SESSION['azure_mail'], $azureMailInDb);

/* Check that the user is logged in */
$result->assertSessionHas('logged_in', true);

/* Check if user has been redirected correctly */
$result->assertRedirect();
$result->assertRedirectTo($redirect_url);
}

/**
Expand Down

0 comments on commit 738c695

Please sign in to comment.