Skip to content

Issue #55: [UPD] make userkey respect suspended status of users #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: MOODLE_33PLUS
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ public function user_login_userkey() {
$this->userkeymanager->delete_keys($key->userid);

$user = get_complete_user_data('id', $key->userid);
if (!empty($user->suspended)) {
$failurereason = AUTH_LOGIN_SUSPENDED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really need this variable? Could be passed as is to the code below.


// Trigger login failed event.
$event = \core\event\user_login_failed::create(array('userid' => $user->id,
'other' => array('username' => $user->username, 'reason' => $failurereason)));
$event->trigger();
error_log('[client '.getremoteaddr()."] $CFG->wwwroot Suspended Login: $user->username ".$_SERVER['HTTP_USER_AGENT']);
throw new invalid_parameter_exception('User suspended');
Copy link
Member

@dmitriim dmitriim Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this error will be displayed to a user, can we please replace this with moodle_exception + add a lang string so it could be localised.

}
complete_user_login($user);

// Identify this session as using user key auth method.
Expand Down