Skip to content

Commit eb2a2be

Browse files
committed
fixed some lint errors
1 parent 3ac690c commit eb2a2be

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

includes/SSO_Helpers.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ class SSO_Helpers {
1717
/**
1818
* Generate an SSO token for a user.
1919
*
20-
* @param int $user_id
20+
* @param int $user_id user id
2121
*
2222
* @return string
2323
*/
2424
public static function generateToken( $user_id ) {
2525
return base64_encode(
2626
implode(
2727
':',
28-
[
28+
array(
2929
$user_id,
3030
time(),
31-
wp_generate_password( 64, true, true )
32-
]
31+
wp_generate_password( 64, true, true ),
32+
)
3333
)
3434
);
3535
}
@@ -129,7 +129,7 @@ public static function shouldThrottle() {
129129
*
130130
* @param string $error_type type of error
131131
*/
132-
public static function triggerFailure( $error_type = '') {
132+
public static function triggerFailure( $error_type = '' ) {
133133

134134
self::logFailure();
135135

@@ -146,14 +146,13 @@ public static function triggerFailure( $error_type = '') {
146146
wp_safe_redirect(
147147
add_query_arg(
148148
array(
149-
'error' => $error_type,
149+
'error' => $error_type,
150150
),
151151
wp_login_url()
152152
)
153153
);
154154
}
155155
exit;
156-
157156
}
158157

159158
/**
@@ -181,7 +180,6 @@ public static function triggerSuccess( \WP_User $user ) {
181180

182181
wp_safe_redirect( $redirect );
183182
exit;
184-
185183
}
186184

187185
/**
@@ -219,7 +217,6 @@ public static function getSuccessUrl() {
219217
$url = add_query_arg( $key, $value, $url );
220218
}
221219
}
222-
223220
}
224221

225222
if ( ! $url ) {
@@ -263,13 +260,11 @@ public static function handleLogin( $token ) {
263260

264261
$user = self::getUserFromToken( $token );
265262
if ( $user ) {
266-
if ( preg_match("/['\"\\\\]/", $user->user_login ) ) {
263+
if ( preg_match( "/['\"\\\\]/", $user->user_login ) ) {
267264
self::triggerFailure( 'invalid_username' );
268265
exit;
269266
}
270267
}
271268
self::triggerSuccess( $user );
272-
273269
}
274-
275270
}

includes/SSO_Helpers_Legacy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function handleLegacyLogin( $nonce, $salt ) {
3939
}
4040

4141
if ( $user ) {
42-
if ( preg_match("/['\"\\\\]/", $user->user_login ) ) {
42+
if ( preg_match( "/['\"\\\\]/", $user->user_login ) ) {
4343
self::triggerFailure( 'invalid_username' );
4444
exit;
4545
}

sso.php

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function () {
1515

1616
add_action(
1717
'cli_init',
18-
function() {
18+
function () {
1919
WP_CLI::add_command(
2020
'newfold sso',
2121
'NewFoldLabs\WP\Module\SSO\SSO_CLI',
@@ -28,29 +28,33 @@ function() {
2828
}
2929
);
3030

31-
add_action( 'init',
32-
function() {
31+
add_action(
32+
'init',
33+
function () {
3334
load_plugin_textdomain(
3435
'wp-module-sso',
3536
false,
3637
NFD_SSO_DIR . '/languages'
3738
);
38-
},
39-
100
39+
},
40+
100
4041
);
4142

42-
add_action( 'login_message', function() {
43-
$error = sanitize_key( $_GET['error'] ?? '' );
44-
if ( ! empty( $error ) ) {
45-
$message = '';
46-
switch ( $error ) {
47-
case 'invalid_username':
48-
$message = __( 'SSO failed: username cannot contain invalid characters.', 'wp-module-sso' );
49-
break;
50-
default:
51-
$message = __( 'An unknown error occurred. Please try again.', 'wp-module-sso' );
52-
break;
43+
add_action(
44+
'login_message',
45+
function () {
46+
$error = sanitize_key( $_GET['error'] ?? '' );
47+
if ( ! empty( $error ) ) {
48+
$message = '';
49+
switch ( $error ) {
50+
case 'invalid_username':
51+
$message = __( 'SSO failed: username cannot contain invalid characters.', 'wp-module-sso' );
52+
break;
53+
default:
54+
$message = __( 'An unknown error occurred. Please try again.', 'wp-module-sso' );
55+
break;
56+
}
57+
return "<div class='login-error' style='color: red; font-weight: bold;'>{$message}</div>";
5358
}
54-
return "<div class='login-error' style='color: red; font-weight: bold;'>{$message}</div>";
5559
}
56-
});
60+
);

0 commit comments

Comments
 (0)