Browse Source

Failed tokens moved to adminLogin for a better user experience

Signed-off-by: emanuele <[email protected]>
emanuele 12 years ago
parent
commit
ef213355a2
2 changed files with 12 additions and 2 deletions
  1. 8 1
      Sources/Security.php
  2. 4 1
      Sources/Subs-Auth.php

+ 8 - 1
Sources/Security.php

@@ -754,7 +754,7 @@ function createToken($action, $type = 'post')
  */
 function validateToken($action, $type = 'post', $reset = true)
 {
-	global $modSettings;
+	global $modSettings, $sourcedir;
 
 	$type = $type == 'get' || $type == 'request' ? $type : 'post';
 
@@ -783,6 +783,13 @@ function validateToken($action, $type = 'post', $reset = true)
 		// I'm back baby.
 		createToken($action, $type);
 
+		// Need to type in a password for that, man.
+		if (!isset($_GET['xml']))
+		{
+			require_once($sourcedir . '/Subs-Auth.php');
+			adminLogin($type, $action);
+		}
+
 		fatal_lang_error('token_verify_fail', false);
 	}
 	// Remove this token as its useless

+ 4 - 1
Sources/Subs-Auth.php

@@ -193,7 +193,7 @@ function InMaintenance()
  *
  * @param string $type = 'admin'
  */
-function adminLogin($type = 'admin')
+function adminLogin($type = 'admin', $additionalToken = false)
 {
 	global $context, $scripturl, $txt, $user_info, $user_settings;
 
@@ -230,6 +230,9 @@ function adminLogin($type = 'admin')
 	foreach ($_POST as $k => $v)
 		$context['post_data'] .= adminLogin_outputPostVars($k, $v);
 
+	if (!empty($additionalToken))
+		$context['post_data'] .= adminLogin_outputPostVars($context[$additionalToken . '_token_var'], $context[$additionalToken . '_token']);
+
 	// Now we'll use the admin_login sub template of the Login template.
 	$context['sub_template'] = 'admin_login';