MDL-48691 webservices: Check if the user must be changing password
authorJuan Leyva <juanleyvadelgado@gmail.com>
Thu, 29 Jan 2015 15:56:20 +0000 (16:56 +0100)
committerDan Poltawski <dan@moodle.com>
Mon, 2 Mar 2015 14:39:52 +0000 (14:39 +0000)
login/token.php

index 19a9eae..ee4d6ca 100644 (file)
@@ -64,6 +64,15 @@ if (!empty($user)) {
         }
     }
 
+    // Check whether the user should be changing password.
+    if (get_user_preferences('auth_forcepasswordchange', false, $user)) {
+        if ($userauth->can_change_password()) {
+            throw new moodle_exception('forcepasswordchangenotice');
+        } else {
+            throw new moodle_exception('nopasswordchangeforced', 'auth');
+        }
+    }
+
     // let enrol plugins deal with new enrolments if necessary
     enrol_check_plugins($user);