Skip to content

Commit 5c93907

Browse files
committed
Fix code style
1 parent 8ac013b commit 5c93907

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

src/Auth/Source/External.php

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,22 @@
7474
*/
7575
class 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
{

src/Auth/Source/UserPass.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
*/
5757
class UserPass extends UserPassBase
5858
{
59-
6059
/**
6160
* Configuration object.
6261
*
@@ -91,14 +90,16 @@ public function __construct(array $info, array $config)
9190
/**
9291
* Attempt to log in using the given username and password.
9392
*
94-
* On a successful login, this function should return the users attributes. On failure,
95-
* it should throw an exception. If the error was caused by the user entering the wrong
96-
* username or password, a SimpleSAML_Error_Error('WRONGUSERPASS') should be thrown.
93+
* On a successful login, this function should return the users attributes.
94+
* On failure, it should throw an exception. If the error was caused by the
95+
* user entering the wrong username or password, a
96+
* SimpleSAML_Error_Error('WRONGUSERPASS') should be thrown.
9797
*
9898
* Note that both the username and the password are UTF-8 encoded.
9999
*
100100
* @param string $username The username the user wrote.
101101
* @param string $password The password the user wrote.
102+
*
102103
* @return array Associative array with the users attributes.
103104
*/
104105
protected function login(string $username, string $password): array

src/ConfigHelper.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
*/
1010
class ConfigHelper
1111
{
12-
13-
1412
/**
1513
* String with the location of this configuration.
1614
* Used for error reporting.
@@ -56,14 +54,15 @@ class ConfigHelper
5654
* @param array $config Configuration.
5755
* @param string $location The location of this configuration. Used for error reporting.
5856
*/
59-
public function __construct(array $config, string $location) {
60-
assert(is_array($config));
61-
assert(is_string($location));
57+
public function __construct(array $config, string $location)
58+
{
59+
assert(is_array($config));
60+
assert(is_string($location));
6261

63-
$this->location = $location;
62+
$this->location = $location;
6463

6564
/* Get authsource configuration. */
66-
$config = Configuration::loadFromArray($config, $location);
65+
$config = Configuration::loadFromArray($config, $location);
6766

6867
$this->drupalroot = $config->getString('drupalroot');
6968
$this->debug = $config->getOptionalBoolean('debug', false);

src/DrupalHelper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace SimpleSAML\Module\drupalauth;
54

65
use Drupal\Core\DrupalKernel;

0 commit comments

Comments
 (0)