7474 */
7575class External extends Source
7676{
77+ /**
78+ * The string used to identify Drupal user ID.
79+ */
80+ public const DRUPALAUTH_EXTERNAL_USER_ID = 'drupalauth:External:UserID ' ;
7781
78- /**
79- * The string used to identify Drupal user ID.
80- */
81- const DRUPALAUTH_EXTERNAL_USER_ID = 'drupalauth:External:UserID ' ;
82-
83- /**
84- * The string used to identify authentication source.
85- */
86- const DRUPALAUTH_AUTH_ID = 'drupalauth:AuthID ' ;
82+ /**
83+ * The string used to identify authentication source.
84+ */
85+ public const DRUPALAUTH_AUTH_ID = 'drupalauth:AuthID ' ;
8786
88- /**
89- * The string used to identify our states.
90- */
91- const DRUPALAUTH_EXTERNAL = 'drupalauth:External ' ;
87+ /**
88+ * The string used to identify our states.
89+ */
90+ public const DRUPALAUTH_EXTERNAL = 'drupalauth:External ' ;
9291
93- /**
92+ /**
9493 * Configuration object.
9594 *
9695 * @var \SimpleSAML\Module\drupalauth\ConfigHelper
@@ -120,19 +119,19 @@ public function __construct(array $info, array $config)
120119 $ this ->config = $ drupalAuthConfig ;
121120 }
122121
123-
124122 /**
125123 * Retrieve attributes for the user.
126124 *
127- * @return array|NULL The user's attributes, or NULL if the user isn't authenticated.
125+ * @return array|NULL The user's attributes, or NULL if the user isn't
126+ * authenticated.
128127 */
129128 private function getUser ($ drupaluid ): ?array
130129 {
131130 if (!empty ($ drupaluid )) {
132131 $ drupalHelper = new DrupalHelper ();
133132 $ drupalHelper ->bootDrupal ($ this ->config ->getDrupalroot ());
134133
135- // Load the user object from Drupal.
134+ // Load the user object from Drupal.
136135 $ drupaluser = User::load ($ drupaluid );
137136 if ($ drupaluser ->isBlocked ()) {
138137 throw new Error ('NOACCESS ' );
@@ -142,26 +141,28 @@ private function getUser($drupaluid): ?array
142141
143142 return $ drupalHelper ->getAttributes ($ drupaluser , $ requested_attributes );
144143 }
144+
145+ return null ;
145146 }
146147
147148 /**
148149 * Log in using an external authentication helper.
149150 *
150- * @param array &$state Information about the current authentication.
151+ * @param array &$state Information about the current authentication.
151152 */
152153 public function authenticate (array &$ state ): void
153154 {
154155 assert (is_array ($ state ));
155156
156- /*
157+ /*
157158 * The user is already authenticated.
158159 *
159160 * Add the users attributes to the $state-array, and return control
160161 * to the authentication process.
161162 */
162- if (!empty ($ state [self ::DRUPALAUTH_EXTERNAL_USER_ID ])) {
163- $ state ['Attributes ' ] = $ this ->getUser ($ state [self ::DRUPALAUTH_EXTERNAL_USER_ID ]);
164- return ;
163+ if (!empty ($ state [self ::DRUPALAUTH_EXTERNAL_USER_ID ])) {
164+ $ state ['Attributes ' ] = $ this ->getUser ($ state [self ::DRUPALAUTH_EXTERNAL_USER_ID ]);
165+ return ;
165166 }
166167
167168 /*
@@ -230,7 +231,7 @@ public function authenticate(array &$state): void
230231 * This function resumes the authentication process after the user has
231232 * entered his or her credentials.
232233 *
233- * @param array &$state The authentication state.
234+ * @param array &$state The authentication state.
234235 */
235236 public static function resume ($ stateID )
236237 {
@@ -274,7 +275,7 @@ public static function resume($stateID)
274275 * First we check that the user is acutally logged in, and didn't simply skip the login page.
275276 */
276277 if (empty ($ state [self ::DRUPALAUTH_EXTERNAL_USER_ID ])) {
277- throw new Exception ('User ID is missing. ' );
278+ throw new Exception ('User ID is missing. ' );
278279 }
279280
280281 /*
@@ -306,10 +307,10 @@ public static function resume($stateID)
306307 }
307308
308309 /**
309- * This function is called when the user start a logout operation, for example
310- * by logging out of a SP that supports single logout.
310+ * This function is called when the user start a logout operation, for
311+ * example by logging out of a SP that supports single logout.
311312 *
312- * @param array &$state The logout state array.
313+ * @param array &$state The logout state array.
313314 */
314315 public function logout (array &$ state ): void
315316 {
0 commit comments