Skip to content

Commit

Permalink
Change route tfa/login to tfa/verify
Browse files Browse the repository at this point in the history
  • Loading branch information
Moc committed Jan 27, 2021
1 parent 081d6a7 commit 6bfa19b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
24 changes: 24 additions & 0 deletions admin_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ public function init()
e107::getMessage()->addWarning("TwoFactorAuth debug mode is <strong>enabled</strong>!"); // DO NOT TRANSLATE
}

// Check old files
$old_files = array(
'login.php',
);

foreach($old_files as $old_file)
{
if(file_exists($old_file))
{
@unlink($old_file);

if(file_exists($old_file))
{
e107::getMessage()->addDebug("Please remove the following outdated file: ".$old_file); // DO NOT TRANSLATE
}
else
{
e107::getMessage()->addSuccess("Outdated file removed: ".$old_file);
e107::getPlug()->clearCache()->buildAddonPrefLists();
}
}
}

// Process disabling 2FA for a specific user
if(vartrue($_POST['disable_tfa']))
{
$user_id = key($_POST['disable_tfa']);
Expand Down
8 changes: 4 additions & 4 deletions e_url.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ function config()
{
$config = array();

$config['login'] = array(
$config['verify'] = array(
'alias' => 'tfa',
'regex' => '^{alias}\/login\/?$',
'sef' => '{alias}/login',
'redirect' => '{e_PLUGIN}twofactorauth/login.php',
'regex' => '^{alias}\/verify\/?$',
'sef' => '{alias}/verify',
'redirect' => '{e_PLUGIN}twofactorauth/verify.php',
);

$config['setup'] = array(
Expand Down
10 changes: 5 additions & 5 deletions twofactorauth_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ public function init($user_id)
if($this->tfa_debug)
{
e107::getAdminLog()->addDebug(__LINE__." ".__METHOD__.": 2FA is activated for User ID ".$user_id);
e107::getAdminLog()->addDebug(__LINE__." ".__METHOD__.": User will need to enter digits. Redirect to tfa/login");
e107::getAdminLog()->addDebug(__LINE__." ".__METHOD__.": User will need to enter digits. Redirect to tfa/verify");
e107::getAdminLog()->toFile('twofactorauth', 'TwoFactorAuth Debug Information', true);
}

// Store some information in a session, so we can retrieve it again later
e107::getSession('2fa')->set('user_id', $user_id); // Store User ID
e107::getSession('2fa')->set('previous_page', e_REQUEST_URL); // Store the page the user is logging in from

// Redirect to page to enter TOTP
//e107::redirect(e_PLUGIN_ABS."twofactorauth/login.php");
$url = e107::url('twofactorauth', 'login');
// Redirect to page to enter TOTP
$url = e107::url('twofactorauth', 'verify');
e107::redirect($url);
return true;
return true;

}

public function tfaActivated($user_id)
Expand Down
File renamed without changes.

0 comments on commit 6bfa19b

Please sign in to comment.