Skip to content

Commit e8d53f8

Browse files
committed
adding user creation prevention flag
1 parent ed141e0 commit e8d53f8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

auth.php

+9
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ private function attempt_jwt_login() {
146146

147147
if (!$userExists) {
148148

149+
$preventAutoUserCreation = $this->prevent_auto_user_creation();
150+
if ($preventAutoUserCreation) {
151+
return;
152+
}
153+
149154
$username = $this->get_expected_username($payload);
150155
$password = null;
151156

@@ -361,6 +366,10 @@ private function decode_base_64($encodedStr) {
361366
return base64_decode($b);
362367
}
363368

369+
private function prevent_auto_user_creation() {
370+
return $this->has_env_bool("MOODLE_JWT_PREVENT_AUTO_USER_CREATION");
371+
}
372+
364373
private function has_env_bool($variableName) {
365374
$value = getenv($variableName);
366375
$exists = $value != false;

0 commit comments

Comments
 (0)