Conditions | 5 |
Paths | 10 |
Total Lines | 35 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public static function post($params) |
||
|
|||
23 | { |
||
24 | static $form; |
||
25 | $token = Yii::$app->request->post('reset_token', false); |
||
26 | |||
27 | // Determine the correct scenario to use based upon the reset token |
||
28 | if ($token === false) { |
||
29 | $form = new ResetPassword(['scenario' => ResetPassword::SCENARIO_INIT]); |
||
30 | } else { |
||
31 | $form = new ResetPassword(['scenario' => ResetPassword::SCENARIO_RESET]); |
||
32 | } |
||
33 | |||
34 | // Load the form |
||
35 | if ($form->load(['ResetPassword' => Yii::$app->request->post()])) { |
||
36 | $form->password = Yii::$app->request->post('password', null); |
||
37 | $form->password_verify = Yii::$app->request->post('password_verify', null); |
||
38 | |||
39 | // If the user is authenticated, populate the model |
||
40 | if (!Yii::$app->user->isGuest) { |
||
41 | $user = Yii::$app->yrc->userClass::findOne(['id' => Yii::$app->user->id]); |
||
42 | $form->setUser($user); |
||
43 | } else { |
||
44 | $form->email = Yii::$app->request->post('email', null); |
||
45 | } |
||
46 | |||
47 | // Validate the form and make sure all of the attributes are set, then perform the reset task depending upon the scenario |
||
48 | if ($form->validate()) { |
||
49 | return $form->reset(); |
||
50 | } |
||
51 | |||
52 | throw new HttpException(400, \json_encode($form->getErrors())); |
||
53 | } |
||
54 | |||
55 | return false; |
||
56 | } |
||
57 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.