added email change strategies

This commit is contained in:
Antonio Ramirez
2016-12-10 14:14:42 +01:00
parent 3fe09e3eb3
commit e215fd58bf
19 changed files with 626 additions and 119 deletions

View File

@ -6,13 +6,49 @@ use yii\db\ActiveQuery;
class TokenQuery extends ActiveQuery
{
public function whereIsRecoveryType($userId, $code)
/**
* @param $userId
*
* @return $this
*/
public function whereUserId($userId)
{
return $this->andWhere(['user_id' => $userId, 'code' => $code, 'type' => Token::TYPE_RECOVERY]);
return $this->andWhere(['user_id' => $userId]);
}
public function whereIsConfirmationType($userId, $code)
/**
* @param $code
*
* @return $this
*/
public function whereCode($code)
{
return $this->andWhere(['user_id' => $userId, 'code' => $code, 'type' => Token::TYPE_CONFIRM_NEW_EMAIL]);
return $this->andWhere(['code' => $code]);
}
/**
* @return $this
*/
public function whereIsRecoveryType()
{
return $this->andWhere(['type' => Token::TYPE_RECOVERY]);
}
/**
* @return $this
*/
public function whereIsConfirmationType()
{
return $this->andWhere(['type' => Token::TYPE_CONFIRM_NEW_EMAIL]);
}
/**
* @param array $types
*
* @return $this
*/
public function whereIsTypes(array $types)
{
return $this->andWhere(['in', 'type', $types]);
}
}