Skip to content

Commit

Permalink
MDL-78685 auth_oauth2: Added logged-in status check
Browse files Browse the repository at this point in the history
  • Loading branch information
meirzamoodle authored and HuongNV13 committed Aug 10, 2023
1 parent ad81e6f commit 3d3dd82
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions auth/oauth2/confirm-linkedlogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@
throw new \moodle_exception('cannotfinduser', '', '', $userid);
}

if (!$user->suspended) {
complete_user_login($user);

\core\session\manager::apply_concurrent_login_limit($user->id, session_id());

if ($user->id == $USER->id) {
// Check where to go, $redirect has a higher preference.
if (empty($redirect) and !empty($SESSION->wantsurl) ) {
$redirect = $SESSION->wantsurl;
Expand All @@ -69,14 +65,24 @@
$PAGE->set_heading($COURSE->fullname);
echo $OUTPUT->header();
echo $OUTPUT->box_start('generalbox centerpara boxwidthnormal boxaligncenter');
echo "<h3>".get_string("thanks").", ". fullname($USER) . "</h3>\n";
echo "<h3>".get_string("thanks").", ". fullname($user) . "</h3>\n";
echo "<p>".get_string("confirmed")."</p>\n";
echo $OUTPUT->single_button("$CFG->wwwroot/course/", get_string('courses'));
// If $wantsurl and $redirect are empty, then the button will navigate the identical user to the dashboard.
if ($user->id == $USER->id) {
echo $OUTPUT->single_button("$CFG->wwwroot/course/", get_string('courses'));
} else if (!isloggedin() || isguestuser()) {
echo $OUTPUT->single_button(get_login_url(), get_string('login'));
} else {
echo $OUTPUT->single_button("$CFG->wwwroot/login/logout.php", get_string('logout'));
}
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
exit;
} else {
\core\notification::error(get_string('confirmationinvalid', 'auth_oauth2'));
// Avoid error if logged-in user visiting the page.
if (!isloggedin()) {
\core\notification::error(get_string('confirmationinvalid', 'auth_oauth2'));
}
}

redirect("$CFG->wwwroot/");

0 comments on commit 3d3dd82

Please sign in to comment.