Rename 2FA controller

This commit is contained in:
Frederic Guillot
2016-05-26 21:05:54 -04:00
parent d9101da79e
commit 33dea152fc
9 changed files with 21 additions and 21 deletions

View File

@@ -7,10 +7,10 @@ use Kanboard\Core\Controller\AccessForbiddenException;
/** /**
* Two Factor Auth controller * Two Factor Auth controller
* *
* @package controller * @package Kanboard/Controller
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Twofactor extends UserViewController class TwoFactorController extends UserViewController
{ {
/** /**
* Only the current user can access to 2FA settings * Only the current user can access to 2FA settings
@@ -100,10 +100,10 @@ class Twofactor extends UserViewController
unset($this->sessionStorage->twoFactorSecret); unset($this->sessionStorage->twoFactorSecret);
$this->userSession->disablePostAuthentication(); $this->userSession->disablePostAuthentication();
$this->response->redirect($this->helper->url->to('twofactor', 'index', array('user_id' => $user['id']))); $this->response->redirect($this->helper->url->to('TwoFactorController', 'index', array('user_id' => $user['id'])));
} else { } else {
$this->flash->failure(t('The two factor authentication code is not valid.')); $this->flash->failure(t('The two factor authentication code is not valid.'));
$this->response->redirect($this->helper->url->to('twofactor', 'show', array('user_id' => $user['id']))); $this->response->redirect($this->helper->url->to('TwoFactorController', 'show', array('user_id' => $user['id'])));
} }
} }
@@ -127,7 +127,7 @@ class Twofactor extends UserViewController
$this->userSession->disablePostAuthentication(); $this->userSession->disablePostAuthentication();
$this->flash->success(t('User updated successfully.')); $this->flash->success(t('User updated successfully.'));
$this->response->redirect($this->helper->url->to('twofactor', 'index', array('user_id' => $user['id']))); $this->response->redirect($this->helper->url->to('TwoFactorController', 'index', array('user_id' => $user['id'])));
} }
/** /**
@@ -152,7 +152,7 @@ class Twofactor extends UserViewController
$this->response->redirect($this->helper->url->to('DashboardController', 'show')); $this->response->redirect($this->helper->url->to('DashboardController', 'show'));
} else { } else {
$this->flash->failure(t('The two factor authentication code is not valid.')); $this->flash->failure(t('The two factor authentication code is not valid.'));
$this->response->redirect($this->helper->url->to('twofactor', 'code')); $this->response->redirect($this->helper->url->to('TwoFactorController', 'code'));
} }
} }

View File

@@ -19,7 +19,7 @@ class PostAuthenticationMiddleware extends BaseMiddleware
{ {
$controller = strtolower($this->router->getController()); $controller = strtolower($this->router->getController());
$action = strtolower($this->router->getAction()); $action = strtolower($this->router->getAction());
$ignore = ($controller === 'twofactor' && in_array($action, array('code', 'check'))) || ($controller === 'auth' && $action === 'logout'); $ignore = ($controller === 'twofactorcontroller' && in_array($action, array('code', 'check'))) || ($controller === 'auth' && $action === 'logout');
if ($ignore === false && $this->userSession->hasPostAuthentication() && ! $this->userSession->isPostAuthenticationValidated()) { if ($ignore === false && $this->userSession->hasPostAuthentication() && ! $this->userSession->isPostAuthenticationValidated()) {
$this->nextMiddleware = null; $this->nextMiddleware = null;
@@ -28,7 +28,7 @@ class PostAuthenticationMiddleware extends BaseMiddleware
$this->response->text('Not Authorized', 401); $this->response->text('Not Authorized', 401);
} }
$this->response->redirect($this->helper->url->to('twofactor', 'code')); $this->response->redirect($this->helper->url->to('TwoFactorController', 'code'));
} }
$this->next(); $this->next();

View File

@@ -140,7 +140,7 @@ class AuthenticationProvider implements ServiceProviderInterface
$acl->add('Link', '*', Role::APP_ADMIN); $acl->add('Link', '*', Role::APP_ADMIN);
$acl->add('ProjectCreation', 'create', Role::APP_MANAGER); $acl->add('ProjectCreation', 'create', Role::APP_MANAGER);
$acl->add('Projectuser', '*', Role::APP_MANAGER); $acl->add('Projectuser', '*', Role::APP_MANAGER);
$acl->add('Twofactor', 'disable', Role::APP_ADMIN); $acl->add('TwoFactorController', 'disable', Role::APP_ADMIN);
$acl->add('UserImportController', '*', Role::APP_ADMIN); $acl->add('UserImportController', '*', Role::APP_ADMIN);
$acl->add('UserCreationController', '*', Role::APP_ADMIN); $acl->add('UserCreationController', '*', Role::APP_ADMIN);
$acl->add('UserListController', '*', Role::APP_ADMIN); $acl->add('UserListController', '*', Role::APP_ADMIN);

View File

@@ -153,7 +153,7 @@ class RouteProvider implements ServiceProviderInterface
$container['route']->addRoute('user/:user_id/accounts', 'UserViewController', 'external'); $container['route']->addRoute('user/:user_id/accounts', 'UserViewController', 'external');
$container['route']->addRoute('user/:user_id/integrations', 'UserViewController', 'integrations'); $container['route']->addRoute('user/:user_id/integrations', 'UserViewController', 'integrations');
$container['route']->addRoute('user/:user_id/authentication', 'UserCredentialController', 'changeAuthentication'); $container['route']->addRoute('user/:user_id/authentication', 'UserCredentialController', 'changeAuthentication');
$container['route']->addRoute('user/:user_id/2fa', 'twofactor', 'index'); $container['route']->addRoute('user/:user_id/2fa', 'TwoFactorController', 'index');
$container['route']->addRoute('user/:user_id/avatar', 'AvatarFile', 'show'); $container['route']->addRoute('user/:user_id/avatar', 'AvatarFile', 'show');
// Groups // Groups

View File

@@ -1,4 +1,4 @@
<form method="post" action="<?= $this->url->href('twofactor', 'check', array('user_id' => $this->user->getId())) ?>" autocomplete="off"> <form method="post" action="<?= $this->url->href('TwoFactorController', 'check', array('user_id' => $this->user->getId())) ?>" autocomplete="off">
<?= $this->form->csrf() ?> <?= $this->form->csrf() ?>
<?= $this->form->label(t('Code'), 'code') ?> <?= $this->form->label(t('Code'), 'code') ?>
@@ -7,4 +7,4 @@
<div class="form-actions"> <div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Check my code') ?></button> <button type="submit" class="btn btn-blue"><?= t('Check my code') ?></button>
</div> </div>
</form> </form>

View File

@@ -8,7 +8,7 @@
</p> </p>
<div class="form-actions"> <div class="form-actions">
<?= $this->url->link(t('Yes'), 'twofactor', 'disable', array('user_id' => $user['id'], 'disable' => 'yes'), true, 'btn btn-red') ?> <?= $this->url->link(t('Yes'), 'TwoFactorController', 'disable', array('user_id' => $user['id'], 'disable' => 'yes'), true, 'btn btn-red') ?>
<?= t('or') ?> <?= $this->url->link(t('cancel'), 'UserViewController', 'show', array('user_id' => $user['id'])) ?> <?= t('or') ?> <?= $this->url->link(t('cancel'), 'UserViewController', 'show', array('user_id' => $user['id'])) ?>
</div> </div>
</div> </div>

View File

@@ -2,7 +2,7 @@
<h2><?= t('Two factor authentication') ?></h2> <h2><?= t('Two factor authentication') ?></h2>
</div> </div>
<form method="post" action="<?= $this->url->href('twofactor', $user['twofactor_activated'] == 1 ? 'deactivate' : 'show', array('user_id' => $user['id'])) ?>" autocomplete="off"> <form method="post" action="<?= $this->url->href('TwoFactorController', $user['twofactor_activated'] == 1 ? 'deactivate' : 'show', array('user_id' => $user['id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?> <?= $this->form->csrf() ?>
<p><?= t('Two-Factor Provider: ') ?><strong><?= $this->text->e($provider) ?></strong></p> <p><?= t('Two-Factor Provider: ') ?><strong><?= $this->text->e($provider) ?></strong></p>
<div class="form-actions"> <div class="form-actions">

View File

@@ -19,7 +19,7 @@
<?php endif ?> <?php endif ?>
<h3><?= t('Test your device') ?></h3> <h3><?= t('Test your device') ?></h3>
<form method="post" action="<?= $this->url->href('twofactor', 'test', array('user_id' => $user['id'])) ?>" autocomplete="off"> <form method="post" action="<?= $this->url->href('TwoFactorController', 'test', array('user_id' => $user['id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?> <?= $this->form->csrf() ?>
<?= $this->form->label(t('Code'), 'code') ?> <?= $this->form->label(t('Code'), 'code') ?>
@@ -28,4 +28,4 @@
<div class="form-actions"> <div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Check my code') ?></button> <button type="submit" class="btn btn-blue"><?= t('Check my code') ?></button>
</div> </div>
</form> </form>

View File

@@ -49,12 +49,12 @@
<?php endif ?> <?php endif ?>
<?php if ($this->user->isCurrentUser($user['id'])): ?> <?php if ($this->user->isCurrentUser($user['id'])): ?>
<li <?= $this->app->checkMenuSelection('twofactor', 'index') ?>> <li <?= $this->app->checkMenuSelection('TwoFactorController', 'index') ?>>
<?= $this->url->link(t('Two factor authentication'), 'twofactor', 'index', array('user_id' => $user['id'])) ?> <?= $this->url->link(t('Two factor authentication'), 'TwoFactorController', 'index', array('user_id' => $user['id'])) ?>
</li> </li>
<?php elseif ($this->user->hasAccess('twofactor', 'disable') && $user['twofactor_activated'] == 1): ?> <?php elseif ($this->user->hasAccess('TwoFactorController', 'disable') && $user['twofactor_activated'] == 1): ?>
<li <?= $this->app->checkMenuSelection('twofactor', 'disable') ?>> <li <?= $this->app->checkMenuSelection('TwoFactorController', 'disable') ?>>
<?= $this->url->link(t('Two factor authentication'), 'twofactor', 'disable', array('user_id' => $user['id'])) ?> <?= $this->url->link(t('Two factor authentication'), 'TwoFactorController', 'disable', array('user_id' => $user['id'])) ?>
</li> </li>
<?php endif ?> <?php endif ?>