1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48:
<?php
/**
* MvcCore
*
* This source file is subject to the BSD 3 License
* For the full copyright and license information, please view
* the LICENSE.md file that are distributed with this source code.
*
* @copyright Copyright (c) 2016 Tom FlĂdr (https://github.com/mvccore/mvccore)
* @license https://mvccore.github.io/docs/mvccore/4.0.0/LICENCE.md
*/
namespace MvcCore\Ext\Auth;
class Controller extends Virtual\Controller {
/**
* Authentication form submit action to sign in.
* Routed by route configured by:
* MvcCore\Ext\Auth::GetInstance()->SetSignInRoute();
* @return void
*/
public function SignInAction () {
/** @var $form \MvcCore\Ext\Auth\SignInForm */
$form = \MvcCore\Ext\Auth::GetInstance()->GetForm();
list ($result, $data, $errors) = $form->Submit();
if ($result !== \MvcCore\Ext\Form::RESULT_SUCCESS) {
// here you can count bad login requests
// to ban danger user for some time or anything else...
}
$form->ClearSession(); // to remove all submited data from session
$form->RedirectAfterSubmit();
}
/**
* Authentication form submit action to sign out.
* Routed by route configured by:
* MvcCore\Ext\Auth::GetInstance()->SetSignOutRoute();
* @return void
*/
public function SignOutAction () {
/** @var $form \MvcCore\Ext\Auth\SignOutForm */
$form = \MvcCore\Ext\Auth::GetInstance()->GetForm();
/*list ($result, $data, $errors) = */$form->Submit();
$form->ClearSession(); // to remove all submited data from session
$form->RedirectAfterSubmit();
}
}