Skip to content

Commit 44afc5e

Browse files
committed
Check ID first
1 parent 5e64676 commit 44afc5e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

lib/Auth/Source/External.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,15 @@ public function authenticate(&$state)
153153
{
154154
assert(is_array($state));
155155

156-
$attributes = $this->getUser($state[self::DRUPALAUTH_EXTERNAL_USER_ID]);
157-
if ($attributes !== null) {
158-
/*
159-
* The user is already authenticated.
160-
*
161-
* Add the users attributes to the $state-array, and return control
162-
* to the authentication process.
163-
*/
164-
$state['Attributes'] = $attributes;
165-
return;
156+
/*
157+
* The user is already authenticated.
158+
*
159+
* Add the users attributes to the $state-array, and return control
160+
* to the authentication process.
161+
*/
162+
if (!empty($state[self::DRUPALAUTH_EXTERNAL_USER_ID])) {
163+
$state['Attributes'] = $this->getUser($state[self::DRUPALAUTH_EXTERNAL_USER_ID]);
164+
return;
166165
}
167166

168167
/*
@@ -271,11 +270,16 @@ public static function resume($stateID)
271270
throw new Exception('Authentication source type changed.');
272271
}
273272

274-
/*
275-
* OK, now we know that our current state is sane. Time to actually log the user in.
276-
*
277-
* First we check that the user is acutally logged in, and didn't simply skip the login page.
278-
*/
273+
/*
274+
* First we check that the user is acutally logged in, and didn't simply skip the login page.
275+
*/
276+
if (empty($state[self::DRUPALAUTH_EXTERNAL_USER_ID])) {
277+
throw new Exception('User ID is missing.');
278+
}
279+
280+
/*
281+
* OK, now we know that our current state is sane. Time to actually log the user in.
282+
*/
279283
$attributes = $source->getUser($state[self::DRUPALAUTH_EXTERNAL_USER_ID]);
280284
if ($attributes === null) {
281285
/*

0 commit comments

Comments
 (0)