Explorar el Código

Added Remember me length in days and default option for login page

causefx hace 7 años
padre
commit
79463ae722

+ 3 - 1
api/config/default.php

@@ -190,5 +190,7 @@ return array(
 	'unsortedTabs' => 'top',
 	'cacheImageSize' => '2',
 	'plexoAuth' => false,
-	'statusSounds' => false
+	'statusSounds' => false,
+	'rememberMeDays' => '7',
+	'rememberMe' => true
 );

+ 1 - 1
api/functions/api-functions.php

@@ -21,7 +21,7 @@ function login($array)
 		}
 	}
 	$username = strtolower($username);
-	$days = (isset($remember)) ? 7 : 1;
+	$days = (isset($remember)) ? $GLOBALS['rememberMeDays'] : 1;
 	$oAuth = (isset($oAuth)) ? $oAuth : false;
 	try {
 		$database = new Dibi\Connection([

+ 1 - 1
api/functions/auth-functions.php

@@ -25,7 +25,7 @@ function authRegister($username, $password, $defaults, $email, $token = null)
 			);
 			phpmSendEmail($sendEmail);
 		}
-		if (createToken($username, $email, gravatar($email), $defaults['group'], $defaults['group_id'], $GLOBALS['organizrHash'], 7)) {
+		if (createToken($username, $email, gravatar($email), $defaults['group'], $defaults['group_id'], $GLOBALS['organizrHash'], $GLOBALS['rememberMeDays'])) {
 			writeLoginLog($username, 'success');
 			writeLog('success', 'Login Function - A User has logged in', $username);
 			return true;

+ 34 - 13
api/functions/organizr-functions.php

@@ -71,6 +71,10 @@ function organizrSpecialSettings()
 		'user' => array(
 			'agent' => isset($_SERVER ['HTTP_USER_AGENT']) ? $_SERVER ['HTTP_USER_AGENT'] : null,
 		),
+		'login' => array(
+			'rememberMe' => $GLOBALS['rememberMe'],
+			'rememberMeDays' => $GLOBALS['rememberMeDays'],
+		),
 		'misc' => array(
 			'installedPlugins' => $GLOBALS['installedPlugins'],
 			'installedThemes' => $GLOBALS['installedThemes'],
@@ -157,7 +161,7 @@ function register($array)
 		writeLog('success', 'Registration Function - Registration Password Verified', $username);
 		if (createUser($username, $password, $defaults, $email)) {
 			writeLog('success', 'Registration Function - A User has registered', $username);
-			if (createToken($username, $email, gravatar($email), $defaults['group'], $defaults['group_id'], $GLOBALS['organizrHash'], 1)) {
+			if (createToken($username, $email, gravatar($email), $defaults['group'], $defaults['group_id'], $GLOBALS['organizrHash'], $GLOBALS['rememberMeDays'])) {
 				writeLoginLog($username, 'success');
 				writeLog('success', 'Login Function - A User has logged in', $username);
 				return true;
@@ -547,12 +551,6 @@ function getSettingsMain()
 				'value' => $GLOBALS['lockoutTimeout'],
 				'placeholder' => ''
 			),
-			array(
-				'type' => 'switch',
-				'name' => 'lockoutSystem',
-				'label' => 'Inactivity Lock',
-				'value' => $GLOBALS['lockoutSystem']
-			),
 			array(
 				'type' => 'select',
 				'name' => 'lockoutMinAuth',
@@ -567,6 +565,22 @@ function getSettingsMain()
 				'value' => $GLOBALS['lockoutMaxAuth'],
 				'options' => groupSelect()
 			),
+			array(
+				'type' => 'switch',
+				'name' => 'lockoutSystem',
+				'label' => 'Inactivity Lock',
+				'value' => $GLOBALS['lockoutSystem']
+			),
+			array(
+				'type' => 'switch',
+				'name' => 'authDebug',
+				'label' => 'Nginx Auth Debug',
+				'help' => 'Important! Do not keep this enabled for too long as this opens up Authentication while testing.',
+				'value' => $GLOBALS['authDebug'],
+				'class' => 'authDebug'
+			)
+		),
+		'Login' => array(
 			array(
 				'type' => 'password-alt',
 				'name' => 'registrationPassword',
@@ -579,14 +593,21 @@ function getSettingsMain()
 				'label' => 'Hide Registration',
 				'value' => $GLOBALS['hideRegistration'],
 			),
+			array(
+				'type' => 'number',
+				'name' => 'rememberMeDays',
+				'label' => 'Remember Me Length',
+				'help' => 'Number of days cookies and tokens will be valid for',
+				'value' => $GLOBALS['rememberMeDays'],
+				'placeholder' => ''
+			),
 			array(
 				'type' => 'switch',
-				'name' => 'authDebug',
-				'label' => 'Nginx Auth Debug',
-				'help' => 'Important! Do not keep this enabled for too long as this opens up Authentication while testing.',
-				'value' => $GLOBALS['authDebug'],
-				'class' => 'authDebug'
-			)
+				'name' => 'rememberMe',
+				'label' => 'Remember Me',
+				'help' => 'Default status of Remember Me button on login screen',
+				'value' => $GLOBALS['rememberMe'],
+			),
 		),
 		'Ping' => array(
 			array(

+ 3 - 3
api/functions/sso-functions.php

@@ -3,19 +3,19 @@ function ssoCheck($username, $password, $token = null)
 {
 	$test = '';
 	if ($GLOBALS['ssoPlex'] && $token) {
-		coookie('set', 'mpt', $token, 7);
+		coookie('set', 'mpt', $token, $GLOBALS['rememberMeDays']);
 	}
 	if ($GLOBALS['ssoOmbi']) {
 		$ombiToken = getOmbiToken($username, $password, $token);
 		if ($ombiToken) {
-			coookie('set', 'Auth', $ombiToken, 7, false);
+			coookie('set', 'Auth', $ombiToken, $GLOBALS['rememberMeDays'], false);
 		}
 	}
 	if ($GLOBALS['ssoTautulli']) {
 		$tautulliToken = getTautulliToken($username, $password, $token);
 		if ($tautulliToken) {
 			foreach ($tautulliToken as $key => $value) {
-				coookie('set', 'tautulli_token_' . $value['uuid'], $value['token'], 7, false);
+				coookie('set', 'tautulli_token_' . $value['uuid'], $value['token'], $GLOBALS['rememberMeDays'], false);
 			}
 		}
 	}

+ 4 - 1
api/pages/login.php

@@ -1,6 +1,9 @@
 <?php
 $pageLogin = '
 <script>
+if(activeInfo.settings.login.rememberMe){
+	$(\'#checkbox-login\').prop(\'checked\',true);
+}
 </script>
 <section id="wrapper" class="login-register">
   <div class="login-box login-sidebar animated slideInRight">
@@ -51,7 +54,7 @@ $pageLogin = '
         <div class="form-group">
           <div class="col-md-12">
             <div class="checkbox checkbox-primary pull-left p-t-0 remember-me">
-              <input id="checkbox-login" name="remember" type="checkbox" checked>
+              <input id="checkbox-login" name="remember" type="checkbox">
               <label for="checkbox-login" lang="en">Remember Me</label>
             </div>
         	</div>