MDL-59275 auth: prevent user login failed coding error

This commit is contained in:
Simey Lameze 2017-06-19 12:08:05 +08:00
parent 6bb80a1917
commit 92c8cb9d98

View File

@ -346,7 +346,7 @@ class auth extends \auth_plugin_base {
* Complete the login process after oauth handshake is complete.
* @param \core\oauth2\client $client
* @param string $redirecturl
* @return none Either redirects or throws an exception
* @return void Either redirects or throws an exception
*/
public function complete_login(client $client, $redirecturl) {
global $CFG, $SESSION, $PAGE;
@ -356,7 +356,7 @@ class auth extends \auth_plugin_base {
if (!$userinfo) {
// Trigger login failed event.
$failurereason = AUTH_LOGIN_NOUSER;
$event = \core\event\user_login_failed::create(['other' => ['username' => $userinfo['username'],
$event = \core\event\user_login_failed::create(['other' => ['username' => 'unknown',
'reason' => $failurereason]]);
$event->trigger();
@ -368,7 +368,7 @@ class auth extends \auth_plugin_base {
if (empty($userinfo['username']) || empty($userinfo['email'])) {
// Trigger login failed event.
$failurereason = AUTH_LOGIN_NOUSER;
$event = \core\event\user_login_failed::create(['other' => ['username' => $userinfo['username'],
$event = \core\event\user_login_failed::create(['other' => ['username' => 'unknown',
'reason' => $failurereason]]);
$event->trigger();