Esempio n. 1
0
 public function getByUsername($username)
 {
     return ShUser::find()->where(['username' => $username])->one();
 }
Esempio n. 2
0
 public function actionPwdreset()
 {
     if (Yii::$app->request->isPost) {
         $model = ShUser::findOne(Yii::$app->sh_user->getIdentity()->getId());
         if ($model == null) {
             $this->ajax_return(false, '登录已超时,请重新登录!');
         }
         $passwd = Yii::$app->request->getBodyParam('passwd');
         $passwd2 = Yii::$app->request->getBodyParam('passwd2');
         //验证密码
         if (strlen($passwd) < 6) {
             $this->ajax_return(false, '密码长度必须大于等于6位!');
         }
         if ($passwd != $passwd2) {
             $this->ajax_return(false, '2次输入的密码不相同!');
         }
         $model->passwd = ShUser::genPasswd($passwd);
         if ($model->save()) {
             $this->ajax_return(true, '操作成功');
         } else {
             $this->ajax_return(false);
         }
     }
     return $this->render('pwdreset');
 }
Esempio n. 3
0
 public function getUser()
 {
     return $this->hasOne(ShUser::className(), ['id' => 'user_id']);
 }