/** * Updates user's password to given. * * @param string $search Email or username * @param string $password New password */ public function actionIndex($search, $password) { $user = $this->finder->findUserByUsernameOrEmail($search); if ($user === null) { $this->stdout(\Yii::t('users', 'User is not found') . "\n", Console::FG_RED); } else { if ($user->resetPassword($password)) { $this->stdout(\Yii::t('users', 'Password has been changed') . "\n", Console::FG_GREEN); } else { $this->stdout(\Yii::t('users', 'Error occurred while changing password') . "\n", Console::FG_RED); } } }
/** * Confirms a user by setting confirmed_at field to current time. * * @param string $search Email or username */ public function actionIndex($search) { $user = $this->finder->findUserByUsernameOrEmail($search); if ($user === null) { $this->stdout(\Yii::t('users', 'User is not found') . "\n", Console::FG_RED); } else { if ($user->confirm()) { $this->stdout(\Yii::t('users', 'User has been confirmed') . "\n", Console::FG_GREEN); } else { $this->stdout(\Yii::t('users', 'Error occurred while confirming user') . "\n", Console::FG_RED); } } }
/** * Deletes a user. * * @param string $search Email or username */ public function actionIndex($search) { if ($this->confirm(\Yii::t('users', 'Are you sure? Deleted user can not be restored'))) { $user = $this->finder->findUserByUsernameOrEmail($search); if ($user === null) { $this->stdout(\Yii::t('users', 'User is not found') . "\n", Console::FG_RED); } else { if ($user->delete()) { $this->stdout(\Yii::t('users', 'User has been deleted') . "\n", Console::FG_GREEN); } else { $this->stdout(\Yii::t('users', 'Error occurred while deleting user') . "\n", Console::FG_RED); } } } }
/** @inheritdoc */ public function beforeValidate() { if (parent::beforeValidate()) { $this->user = $this->finder->findUserByUsernameOrEmail($this->login); return true; } else { return false; } }