1 | <?php |
||
2 | namespace App\Http\Api\Backend\Form; |
||
3 | |||
4 | use App\Factory\SessionFactory; |
||
5 | use App\Http\Form\LoginForm as BaseLoginForm; |
||
6 | use Yii; |
||
7 | |||
8 | class LoginForm extends BaseLoginForm |
||
9 | { |
||
10 | /** |
||
11 | * Logs in a user using the provided username and password. |
||
12 | * |
||
13 | * @return bool whether the user is logged in successfully |
||
14 | */ |
||
15 | 1 | protected function handleInternal() |
|
16 | { |
||
17 | 1 | $transaction = Yii::$app->getDb()->beginTransaction(); |
|
18 | try { |
||
19 | 1 | $user = $this->getUser(); |
|
20 | |||
21 | 1 | $session = SessionFactory::create( |
|
22 | 1 | $user->id, |
|
23 | 1 | Yii::$app->params['user.session.duration'], |
|
24 | 1 | Yii::$app->params['user.session.refreshTokenDuration'], |
|
25 | 1 | Yii::$app->getRequest() |
|
26 | ); |
||
27 | 1 | if (!$session->save()) { |
|
28 | Yii::error($session->getErrors(), __METHOD__); |
||
29 | throw new \RuntimeException('Unable to save session' . \yii\helpers\VarDumper::dumpAsString($session->getErrors())); |
||
30 | } |
||
31 | |||
32 | 1 | Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0); |
|
0 ignored issues
–
show
|
|||
33 | 1 | $transaction->commit(); |
|
34 | |||
35 | return [ |
||
0 ignored issues
–
show
|
|||
36 | 1 | 'id' => $user->id, |
|
37 | 1 | 'username' => $user->username, |
|
38 | 1 | 'email' => $user->email, |
|
39 | 1 | 'token' => $session->token, |
|
40 | 1 | 'expires_in' => $session->getExpiresIn(), |
|
41 | 1 | 'refresh_token' => $session->refresh_token, |
|
42 | 1 | 'refresh_token_expire_in' => $session->getRefreshTokenExpiresIn(), |
|
43 | ]; |
||
44 | } catch (\Throwable $e) { |
||
45 | $transaction->rollBack(); |
||
46 | throw $e; |
||
47 | } |
||
48 | } |
||
49 | } |
||
50 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.