bluzphp /
skeleton
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Login module/controller |
||
| 4 | * |
||
| 5 | * @author Anton Shevchuk |
||
| 6 | * @created 20.07.11 18:39 |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace Application; |
||
| 10 | |||
| 11 | use Application\Auth; |
||
| 12 | use Bluz\Auth\AuthException; |
||
|
0 ignored issues
–
show
|
|||
| 13 | use Bluz\Controller\Controller; |
||
|
0 ignored issues
–
show
The type
Bluz\Controller\Controller was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 14 | use Bluz\Proxy\Messages; |
||
|
0 ignored issues
–
show
The type
Bluz\Proxy\Messages was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 15 | use Bluz\Proxy\Request; |
||
|
0 ignored issues
–
show
The type
Bluz\Proxy\Request was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 16 | use Bluz\Proxy\Response; |
||
|
0 ignored issues
–
show
The type
Bluz\Proxy\Response was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 17 | use Bluz\Proxy\Session; |
||
|
0 ignored issues
–
show
The type
Bluz\Proxy\Session was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 18 | |||
| 19 | /** |
||
| 20 | * @param string $login |
||
| 21 | * @param string $password |
||
| 22 | * @param bool $rememberMe |
||
| 23 | * |
||
| 24 | * @return array |
||
| 25 | */ |
||
| 26 | return function ($login, $password, $rememberMe = false) { |
||
| 27 | /** |
||
| 28 | * @var Controller $this |
||
| 29 | */ |
||
| 30 | |||
| 31 | // change layout |
||
| 32 | 2 | if (!Request::isXmlHttpRequest()) { |
|
| 33 | 2 | $this->useLayout('small.phtml'); |
|
| 34 | } |
||
| 35 | |||
| 36 | 2 | if ($this->user()) { |
|
| 37 | Messages::addNotice('Already signed'); |
||
| 38 | Response::redirectTo('index', 'index'); |
||
| 39 | 2 | } elseif (Request::isPost()) { |
|
| 40 | try { |
||
| 41 | 2 | if (empty($login)) { |
|
| 42 | throw new Exception('Login is empty'); |
||
| 43 | } |
||
| 44 | |||
| 45 | 2 | if (empty($password)) { |
|
| 46 | throw new Exception('Password is empty'); |
||
| 47 | } |
||
| 48 | |||
| 49 | // try to login/password |
||
| 50 | 2 | Auth\Provider\Equals::authenticate($login, $password); |
|
| 51 | |||
| 52 | 1 | if ($rememberMe) { |
|
| 53 | $user = \Bluz\Proxy\Auth::getIdentity(); |
||
|
0 ignored issues
–
show
The type
Bluz\Proxy\Auth was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 54 | Auth\Provider\Cookie::create($user); |
||
| 55 | } |
||
| 56 | |||
| 57 | 1 | Messages::addNotice('You are signed'); |
|
| 58 | |||
| 59 | // try to rollback to previous called URL |
||
| 60 | 1 | if ($rollback = Session::get('rollback')) { |
|
| 61 | Session::delete('rollback'); |
||
| 62 | Response::redirect($rollback); |
||
| 63 | } |
||
| 64 | // try back to index |
||
| 65 | 1 | Response::redirectTo('index', 'index'); |
|
| 66 | 2 | } catch (Exception $e) { |
|
| 67 | Messages::addError($e->getMessage()); |
||
| 68 | return ['login' => $login]; |
||
| 69 | 2 | } catch (AuthException $e) { |
|
| 70 | 1 | Messages::addError($e->getMessage()); |
|
| 71 | 1 | return ['login' => $login]; |
|
| 72 | } |
||
| 73 | } |
||
| 74 | }; |
||
| 75 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths