Code Duplication    Length = 18-18 lines in 2 locations

api/forms/Activation.php 1 location

@@ 43-60 (lines=18) @@
40
     * @param string $attribute
41
     * @param array $params
42
     */
43
    public function belongsToUserAndIsNotExpired($attribute, $params)
44
    {
45
        if (!$this->hasErrors()) {
46
            $tokenInfo = Yii::$app->cache->get(
47
                hash('sha256', $this->activation_code . '_activation_token')
48
            );
49
            
50
            if ($tokenInfo === null) {
51
                $this->addError('activation_code', Yii::t('yrc', 'The activation code provided is not valid.'));
52
            }
53
54
            $this->user = Yii::$app->yrc->userClass::find()->where(['id' => $tokenInfo['id']])->one();
55
56
            if ($this->user === null) {
57
                $this->addError('activation_code', Yii::t('yrc', 'The activation code provided is not valid.'));
58
            }
59
        }
60
    }
61
62
    /**
63
     * Activates the user

api/forms/ResetPassword.php 1 location

@@ 114-131 (lines=18) @@
111
     * Reset token validator
112
     * @inheritdoc
113
     */
114
    public function validateResetToken($attributes, $params)
115
    {
116
        if (!$this->hasErrors()) {
117
            $tokenInfo = Yii::$app->cache->get(
118
                hash('sha256', $this->reset_token . '_reset_token')
119
            );
120
            
121
            if ($tokenInfo === null) {
122
                $this->addError('reset_token', Yii::t('yrc', 'The password reset token provided is not valid.'));
123
            }
124
125
            $this->user = Yii::$app->yrc->userClass::find()->where([
126
                'id' => $tokenInfo['id']
127
            ])->one();
128
129
            if ($this->user === null) {
130
                $this->addError('reset_token', Yii::t('yrc', 'The password reset token provided is not valid.'));
131
            }
132
        }
133
    }
134