| Total Complexity | 10 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | class AuthController |
||
| 21 | { |
||
| 22 | private $auth; |
||
| 23 | |||
| 24 | public function __construct(AuthScope $auth) |
||
| 25 | { |
||
| 26 | $this->auth = $auth; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function do(GuardInterface $guard) |
||
| 30 | { |
||
| 31 | if (!$guard->allows('do')) { |
||
| 32 | throw new ControllerException("Unauthorized permission 'do'", ControllerException::FORBIDDEN); |
||
| 33 | } |
||
| 34 | |||
| 35 | return 'ok'; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function token(AuthContextInterface $authContext) |
||
| 39 | { |
||
| 40 | if ($authContext->getToken() !== null) { |
||
| 41 | return $authContext->getToken()->getID(); |
||
| 42 | } |
||
| 43 | |||
| 44 | return 'none'; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function login(AuthContextInterface $authContext, TokenStorageInterface $tokenStorage) |
||
| 48 | { |
||
| 49 | $authContext->start( |
||
| 50 | $tokenStorage->create(['userID' => 1]) |
||
| 51 | ); |
||
| 52 | |||
| 53 | return 'OK'; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function token2() |
||
| 57 | { |
||
| 58 | if ($this->auth->getToken() !== null) { |
||
| 59 | return $this->auth->getToken()->getID(); |
||
| 60 | } |
||
| 61 | |||
| 62 | return 'none'; |
||
| 63 | } |
||
| 64 | |||
| 65 | public function token3() |
||
| 66 | { |
||
| 67 | return $this->auth->getToken()->getPayload(); |
||
| 68 | } |
||
| 69 | |||
| 70 | public function login2(TokenStorageInterface $tokenStorage) |
||
| 77 | } |
||
| 78 | } |
||
| 79 |