Skip to content

Commit

Permalink
Updated AppController
Browse files Browse the repository at this point in the history
  • Loading branch information
Xety committed Nov 6, 2016
1 parent cd5a82a commit 504498f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -116,6 +116,7 @@ This project implements many features and will implements more in the future. He
|`2FA.recovery_code.regenerate`|Triggered when an user regenerate a new recovery code.|
|`2FA.recovery_code.used`|Triggered when an user use his recovery code.|


* ###### WYSIWYG Editor (CKEditor)
* Articles, Comments

Expand Down
9 changes: 5 additions & 4 deletions src/Controller/AppController.php
Expand Up @@ -102,18 +102,19 @@ public function beforeFilter(Event $event)
if (!$this->Auth->user() && $this->Cookie->read('CookieAuth')) {
$this->loadModel('Users');

$user = $this->Auth->identify();
if ($user && $user['is_deleted'] == false) {
$userLogin = $this->Auth->identify();
if ($userLogin && $userLogin['is_deleted'] == false) {
$this->loadComponent('TwoFactorAuth');

//Verify if the user use 2FA and if yes, if he's authorized.
if ($userLogin['two_factor_auth_enabled'] == true && $this->TwoFactorAuth->isAuthorized($userLogin['id']) === false) {
$this->Cookie->delete('CookieAuth');
} else {
$this->Auth->setUser($user);
$this->Auth->setUser($userLogin);

$user = $this->Users->newEntity($user, ['accessibleFields' => ['id' => true]]);
$user = $this->Users->newEntity($userLogin);
$user->isNew(false);
$user->id = $userLogin['id'];

$user->last_login = new Time();
$user->last_login_ip = $this->request->clientIp();
Expand Down

0 comments on commit 504498f

Please sign in to comment.