Skip to content

Commit da91cb7

Browse files
authored
remove comments and consolidate code
1 parent 91e6b27 commit da91cb7

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

onelogin-saml-sso/php/functions.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
<?php
2-
/*
3-
* includes capabilities for a "remember me" login flag passed as a SAML Attribute.
4-
* To use, pass a value of 'yes' in a SAML Attribute, then map that attribute
5-
* name in the WordPress Dashboard SSO Settings here:
6-
* Wordpress Settings => SSO/SAML Settings => Attribute Mapping => Remember Me
7-
8-
* Other affected files: /php/configuration.php
9-
*/
102

113
// Make sure we don't expose any info if called directly
124
if ( !function_exists( 'add_action' ) ) {
@@ -289,21 +281,12 @@ function saml_acs() {
289281
} else if ($user_id) {
290282
wp_set_current_user($user_id);
291283

284+
$rememberme = false;
292285
$remembermeMapping = get_option('onelogin_saml_attr_mapping_rememberme');
293-
if ( !empty($remembermeMapping) && isset($attrs[$remembermeMapping]) && !empty($attrs[$remembermeMapping][0])) {
294-
$rememberme = $attrs[$remembermeMapping][0];
295-
}
296-
297-
if ( isset($rememberme) ) {
298-
// ** Value of 'yes' is assumed to be passed here, if other, need to edit this.
299-
if ( $rememberme == 'yes' ) {
300-
wp_set_auth_cookie($user_id, true);
301-
} else {
302-
wp_set_auth_cookie($user_id);
303-
}
304-
} else {
305-
wp_set_auth_cookie($user_id);
286+
if (!empty($remembermeMapping) && isset($attrs[$remembermeMapping]) && !empty($attrs[$remembermeMapping][0])) {
287+
$rememberme = in_array($attrs[$remembermeMapping][0], array(1, true, '1', 'yes', 'on')) ? true : false;
306288
}
289+
wp_set_auth_cookie($user_id, $rememberme);
307290

308291
setcookie(SAML_LOGIN_COOKIE, 1, time() + YEAR_IN_SECONDS, SITECOOKIEPATH );
309292
}

0 commit comments

Comments
 (0)