1 | <?php |
||
34 | class SecurityController extends Controller |
||
35 | { |
||
36 | use ContainerAwareTrait; |
||
37 | use ModuleAwareTrait; |
||
38 | |||
39 | protected $socialNetworkAccountQuery; |
||
40 | |||
41 | /** |
||
42 | * SecurityController constructor. |
||
43 | * |
||
44 | * @param string $id |
||
45 | * @param Module $module |
||
46 | * @param SocialNetworkAccountQuery $socialNetworkAccountQuery |
||
47 | * @param array $config |
||
48 | */ |
||
49 | 4 | public function __construct( |
|
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | 4 | public function behaviors() |
|
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | 4 | public function actions() |
|
105 | |||
106 | /** |
||
107 | * Controller action responsible for handling login page and actions. |
||
108 | * |
||
109 | * @throws InvalidConfigException |
||
110 | * @throws InvalidParamException |
||
111 | * @return array|string|Response |
||
112 | */ |
||
113 | 4 | public function actionLogin() |
|
114 | { |
||
115 | 4 | if (!Yii::$app->user->getIsGuest()) { |
|
116 | return $this->goHome(); |
||
117 | } |
||
118 | |||
119 | /** @var LoginForm $form */ |
||
120 | 4 | $form = $this->make(LoginForm::class); |
|
121 | |||
122 | /** @var FormEvent $event */ |
||
123 | 4 | $event = $this->make(FormEvent::class, [$form]); |
|
124 | |||
125 | 4 | if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) { |
|
126 | Yii::$app->response->format = Response::FORMAT_JSON; |
||
127 | |||
128 | return ActiveForm::validate($form); |
||
129 | } |
||
130 | |||
131 | 4 | if ($form->load(Yii::$app->request->post())) { |
|
132 | 4 | if ($this->module->enableTwoFactorAuthentication && $form->validate()) { |
|
133 | if ($form->getUser()->auth_tf_enabled) { |
||
134 | Yii::$app->session->set('credentials', ['login' => $form->login, 'pwd' => $form->password]); |
||
135 | |||
136 | return $this->redirect(['confirm']); |
||
137 | } |
||
138 | } |
||
139 | |||
140 | 4 | $this->trigger(FormEvent::EVENT_BEFORE_LOGIN, $event); |
|
141 | 4 | if ($form->login()) { |
|
142 | 4 | $form->getUser()->updateAttributes([ |
|
143 | 4 | 'last_login_at' => time(), |
|
144 | 4 | 'last_login_ip' => $this->module->disableIpLogging ? '127.0.0.1' : Yii::$app->request->getUserIP(), |
|
145 | ]); |
||
146 | |||
147 | 4 | $this->trigger(FormEvent::EVENT_AFTER_LOGIN, $event); |
|
148 | |||
149 | 4 | return $this->goBack(); |
|
150 | } |
||
151 | else |
||
152 | { |
||
153 | 3 | $this->trigger(FormEvent::EVENT_FAILED_LOGIN, $event); |
|
154 | } |
||
155 | } |
||
156 | |||
157 | 4 | return $this->render( |
|
158 | 4 | 'login', |
|
159 | [ |
||
160 | 4 | 'model' => $form, |
|
161 | 4 | 'module' => $this->module, |
|
162 | ] |
||
163 | ); |
||
164 | } |
||
165 | |||
166 | public function actionConfirm() |
||
214 | |||
215 | public function actionLogout() |
||
227 | |||
228 | public function authenticate(AuthClientInterface $client) |
||
232 | |||
233 | public function connect(AuthClientInterface $client) |
||
243 | } |
||
244 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: