@@ 98-108 (lines=11) @@ | ||
95 | * Validates the users OTP code, if they provided |
|
96 | * @inheritdoc |
|
97 | */ |
|
98 | public function validateOTP($attributes, $params) |
|
99 | { |
|
100 | if (!$this->hasErrors()) { |
|
101 | if ($this->getUser()->isOTPEnabled()) { |
|
102 | if ($this->otp === null || !$this->getUser()->verifyOTP((string)$this->otp)) { |
|
103 | $this->addError('otp', Yii::t('yrc', 'This account is protected with two factor authentication, and a valid OTP code is required to change the password.')); |
|
104 | return; |
|
105 | } |
|
106 | } |
|
107 | } |
|
108 | } |
|
109 | ||
110 | /** |
|
111 | * Validates the users old password |
|
@@ 114-124 (lines=11) @@ | ||
111 | * Validates the users old password |
|
112 | * @inheritdoc |
|
113 | */ |
|
114 | public function validateOldPassword($attributes, $params) |
|
115 | { |
|
116 | if (!$this->hasErrors()) { |
|
117 | if (!$this->getUser()->validatePassword($this->old_password)) { |
|
118 | $this->addError('old_password', Yii::t('yrc', 'Your current password is not valid.')); |
|
119 | return; |
|
120 | } |
|
121 | ||
122 | $this->validateOTP('otp', $this->otp); |
|
123 | } |
|
124 | } |
|
125 | ||
126 | /** |
|
127 | * Validates the authenticated users state |