added email change strategies
This commit is contained in:
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,11 @@ use yii\db\ActiveQuery;
|
||||
|
||||
class UserQuery extends ActiveQuery
|
||||
{
|
||||
/**
|
||||
* @param $usernameOrEmail
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function whereUsernameOrEmail($usernameOrEmail)
|
||||
{
|
||||
return filter_var($usernameOrEmail, FILTER_VALIDATE_EMAIL)
|
||||
@ -13,18 +18,44 @@ class UserQuery extends ActiveQuery
|
||||
: $this->whereUsername($usernameOrEmail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $email
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function whereEmail($email)
|
||||
{
|
||||
return $this->andWhere(['email' => $email]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $username
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function whereUsername($username)
|
||||
{
|
||||
return $this->andWhere(['username' => $username]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function whereId($id)
|
||||
{
|
||||
return $this->andWhere(['id' => $id]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function whereNotId($id)
|
||||
{
|
||||
return $this->andWhere(['<>', 'id', $id]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user