예제 #1
0
 /**
  * 用户修改密码
  * @return array|string
  */
 public function actionChangepassword()
 {
     $result = App::AppGet();
     try {
         if ($result['errorNum']) {
             $result = array('errorNum' => $result['errorNum'], 'errorMsg' => $result['errorMsg'], 'data' => null);
         } else {
             $data = $result['data'];
             if (array_key_exists('uid', $data) && array_key_exists('new_pwd', $data) && array_key_exists('rep_pwd', $data)) {
                 $uid = $data['uid'];
                 $old_pwd = $data['old_pwd'];
                 $new_pwd = $data['new_pwd'];
                 $rep_pwd = $data['rep_pwd'];
                 $result = member::changePassword($uid, $old_pwd, $new_pwd, $rep_pwd);
             } else {
                 $result = array('errorNum' => '1', 'errorMsg' => '参数错误', 'data' => null);
             }
         }
     } catch (ErrorException $e) {
         Yii::error("用户修改密码---异常 方法:actionChangepassword 参数:" . json_encode($result['data']), "app");
         Yii::trace($e->getMessage(), "app");
         $result = array('errorNum' => '7', 'errorMsg' => '服务器异常,请联系管理员', 'data' => null);
     }
     $result = App::AppReturn($result);
     return $result;
 }
예제 #2
0
 public function actionDorepass()
 {
     $uid = Yii::$app->user->id;
     if ($_POST) {
         $member = member::changePassword($uid, $_POST['oldpass'], $_POST['password'], $_POST['repassword']);
         if ($member['errorNum'] == 1) {
             return $member['errorMsg'];
         } else {
             Utils::ensureOpenId();
             $openId = Yii::$app->request->get('open_id');
             if ($openId) {
                 $model = UcenterMember::findOne(['openid' => $openId]);
                 if ($model) {
                     $model->openid = '';
                     $model->save();
                 }
             }
             Yii::$app->user->logout();
             return '修改成功';
         }
     }
 }