/** * @inheritdoc */ public function safeDown() { $authManager = $this->getAuthManager(); $this->db = $authManager->db; $userId = \common\models\User::findByEmail('*****@*****.**')->id; $this->delete($authManager->assignmentTable, ['user_id' => $userId]); }
/** * Finds user by [[username]] * * @return User|null */ public function getUser() { if (!$this->_user) { $this->_user = User::findByEmail($this->username); } return $this->_user; }
public function rules() { return [[['password', 'email', 'title'], 'required', 'on' => self::SCENARIO_NEW], [['email', 'title'], 'required', 'on' => self::SCENARIO_EDIT], ['password', 'string', 'min' => Yii::$app->params['passLength']], ['password_repeat', 'compare', 'compareAttribute' => 'password', 'message' => Yii::t('app', "Passwords don't match")], [['ssid'], 'default', 'value' => helper::getSsid()], [['ssid', 'shop_id'], 'integer'], [['title'], 'string', 'max' => 100], [['description'], 'string', 'max' => 250], 'emailPattern' => ['email', 'email'], 'emailLength' => ['email', 'string', 'max' => 255], 'emailUniqueEdit' => ['email', function ($attribute) { if (User::findByEmail($this->email)) { $this->addError($attribute, $this->email . Yii::t('app', 'Email already exist')); } }, 'when' => function () { $user = User::findByEmail($this->email); if (!empty((array) $user)) { return Yii::$app->user->id != $user->id; // do not check for current user (my email) } }, 'on' => self::SCENARIO_EDIT], 'emailUniqueNew' => ['email', function ($attribute, $params) { $user = User::findByEmail($this->{$attribute}); if (!empty((array) $user)) { $this->addError($attribute, Yii::t('app', 'Email already exist')); } }, 'on' => self::SCENARIO_NEW], 'emailTrim' => ['email', 'trim'], 'oldPassCheck' => ['password_old', function ($attribute) { $user = User::findIdentity($this->id); if (!empty((array) $user)) { if ($user->validatePassword($this->password_old)) { $this->addError($attribute, Yii::t('app', 'Password Do not match')); } } }, 'on' => self::SCENARIO_EDIT]]; }
/** * Finds user by [[username]] * * @return User|null */ public function getUser() { if ($this->_user === false) { $this->_user = User::findByEmail($this->email); } return $this->_user; }
/** * Finds user by [[email]] * * @return User|null */ protected function getUser() { if ($this->_user === null) { $this->_user = User::findByEmail($this->email); } return $this->_user; }
public function getUser() { if ($this->_user === null) { $this->_user = User::findByEmail($this->email); $this->_user = $this->_user ? $this->_user : false; } return $this->_user; }
public static function exsits($email) { $model = User::findByEmail($email); if (isset($model->email)) { return true; } else { return false; } }
/** * email 邮箱登录 * @user onyony * @return bool|null|static */ public function getUser() { if ($this->_user === false) { if (strpos($this->username, "@")) { $this->_user = User::findByEmail($this->username); } else { $this->_user = User::findByUsername($this->username); } } return $this->_user; }
public function getUser() { if ($this->_user === false) { if ($this->scenario === 'loginWithEmail') { $this->_user = User::findByEmail($this->email); } else { $this->_user = User::findByphone($this->phone); } } return $this->_user; }
public function checkEmail($attribute, $params) { if (!$this->hasErrors()) { $exist = User::findByEmail($this->email); if (!$exist) { $this->addError($attribute, 'Sorry the user\'s email doesn\'t exists !!!'); } else { $this->invitee = $exist; } } }
/** * Finds user by username or email in 'lwe' scenario. * * @return User|null|static */ public function getUser() { if ($this->_user === false) { // in 'lwe' scenario we find user by email, otherwise by username if ($this->scenario === 'lwe') { $this->_user = User::findByEmail($this->email); } else { $this->_user = User::findByUsername($this->username); } } return $this->_user; }
public function getUser() { if ($this->_user === false) { $this->_user = User::findByEmail($this->username); if ($this->_user) { return $this->_user; } else { $this->_user = User::findByphone($this->username); } } return $this->_user; }
/** * Finds user by [[username]] * * @return User|null */ protected function getUser() { if ($this->_user === null) { if (\common\components\Utils::isEmail($this->username)) { $this->_user = User::findByEmail($this->username); } else { $this->_user = User::findByUsername($this->username); } } //var_dump($this->_user);//die; return $this->_user; }
/** * Finds user by [[username]] * * @return User|null */ protected function getUser() { if ($this->_user === null) { //Находим пользователя в БД по логину или эл.почте $this->_user = User::findByEmail($this->email); //Проверяем права доступа, если нет, то делаем вид, //что пользователь не найден. if (!Yii::$app->user->can('dashboard', ['user' => $this->_user])) { $this->_user = null; } } return $this->_user; }
/** * Finds user by [[username]] * * @return User|null */ protected function getUser() { if ($this->_user === null) { $this->_user = User::findByUsername($this->username); } if ($this->_user === null) { $this->_user = User::findByEmail($this->username); } if (!Yii::$app->user->can('dashboard', ['user' => $this->_user])) { $this->_user = null; throw new \yii\web\HttpException(403, 'Access is restricted to administrators.', 403); } return $this->_user; }
/** * Finds user by [[username]] * * @return User|null */ public function getUser() { if ($this->_user === false) { $userName = $this->username; if (EasyHelpers::checkEmail($userName)) { // do username; $this->_user = User::findByEmail($userName); } elseif (EasyHelpers::checkMobile($userName)) { // do mobile; $this->_user = User::findByMobile($userName); } else { return false; } } return $this->_user; }
/** * Helper method responsible for finding user based on the model scenario. * In Login With Email 'lwe' scenario we find user by email, otherwise by username * * @return object The found User object. */ private function findUser() { if (!($this->scenario === 'lwe')) { return User::findByUsername($this->username); } return $this->_user = User::findByEmail($this->email); }
public function safeDown() { User::findByEmail('test@loc')->delete(); }
/** * 邮箱注册过则将邮箱置空 */ protected function checkEmail() { if (User::findByEmail($this->email)) { $this->email = ''; } }
public function actionRemoteProceed() { $client = Yii::$app->authClientCollection->getActiveClient(); if (!$client) { return $this->redirect(['login']); } $email = $client->getUserAttributes()['email']; $user = User::findByEmail($email); if ($user) { return $this->redirect(['confirm']); } return $this->redirect(['signup']); #return $this->render('remoteProceed'); }
/** * @return string|\yii\web\Response 登录方法 */ public function actionLogin() { $loginModel = new LoginForm(); if ($loginModel->load(Yii::$app->request->post()) && $loginModel->login()) { //需要处理的错误类型 switch ($loginModel->errorType) { case LoginForm::ERROR_NON: Yii::$app->session->setFlash('alert', '登录成功'); Yii::$app->session->setFlash('alert-type', 'alert-success'); break; case LoginForm::ERROR_WAITFINISH: return $this->redirect(['finish-register', 'uid' => User::findByEmail($loginModel->email, User::STATUS_ALL)->user_id]); break; default: throw new InvalidCallException('login action error'); break; } return $this->goBack(); } else { return $this->render('login', ['loginModel' => $loginModel]); } }
/** * Finds user by [[username]] * * @return User|null */ public function getUser() { $this->_user = User::findByEmail($this->email); return $this->_user; }
public function actionCreate() { $out = ['status' => 'err', 'error' => 'Unknown error']; $order = new Order(); $r = new Request(); if ($order->load($r->post())) { $order->price = $order->price * 100; // $user = \Yii::$app->user; if (\Yii::$app->user->isGuest) { if ($user = User::findByEmail($r->post('SignupForm')['email'])) { $order->user_id = $user->getId(); } else { $signup = new SignupForm(); if ($signup->load($r->post())) { $signup->username = $signup->email; $signup->password = User::MakePass(7); if ($user = $signup->signup()) { $order->user_id = $user->getId(); } else { $out['error'] = array_values($signup->errors)[0][0]; } } else { //vd($signup->errors,1); } } } else { $order->user_id = \Yii::$app->user->getId(); } if ($order->validate() && $order->save()) { //vd([$r->post(),$order->attributes]); $out = ['status' => 'ok', 'order' => $order->id, 'user' => $order->user_id, 'sum' => $order->price / 100]; } else { $out['error'] = array_values($order->errors)[0][0]; //vd($order->errors); } } //vd($out); \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return $out; //return BaseJson::encode($out,JSON_PRETTY_PRINT); /*vd(['get' => $r->getQueryParams() , 'post' => $r->post(), 'order' => $order],1); //*/ }
/** * Finds user by [[username]] * * @return User|null */ protected function getUser() { if ($this->_user === null) { $this->_user = User::findByUsername($this->username); } if ($this->_user === null) { $this->_user = User::findByEmail($this->username); } if ($this->_user === null) { $this->_user = User::findByMobile($this->username); } return $this->_user; }
/** * Finds user by [[username]] * * @return User|null */ protected function getUser() { if ($this->_user === null) { $this->_user = User::findByUsername($this->username); } if ($this->_user === null) { $this->_user = User::findByEmail($this->username); } if ($this->_user === null) { $this->_user = User::findByMobile($this->username); } if ($this->_user && !in_array($this->_user->group, [User::GROUP_ADMIN, User::GROUP_WRITER])) { return false; } return $this->_user; }