/**
  * 验证找回密码
  * @method POST_verifyAction
  * @author NewFuture
  */
 public function POST_verifyAction()
 {
     $response['status'] = 0;
     if (!Input::post('number', $number, 'card')) {
         $response['info'] = '学号格式有误';
     }
     if (!Input::post('password', $password, 'trim')) {
         $response['info'] = '密码无效';
     } elseif (!Input::post('sch_id', $sch_id, 'int')) {
         $response['info'] = '学校ID无效';
     } elseif (!($id = UserModel::where('number', $number)->get('id'))) {
         $response['info'] = '学号错误或者尚未注册过';
     } else {
         $info = ['number' => $number, 'password' => $password, 'sch_id' => $sch_id];
         if (Input::post('code', $code, 'ctype_alnum')) {
             /*验证码*/
             $info['code'] = $code;
         }
         /*学校系统验证*/
         if (School::verify($info)) {
             /*验证成功*/
             $user['id'] = $id;
             $user['number'] = $number;
             Session::set('find_user', $user);
             $response['status'] = 1;
             $response['info'] = '验证成功,请重置密码';
         } else {
             $response['info'] = '验证失败';
         }
     }
     $this->response = $response;
 }
Exemple #2
0
 /**
  * 验证准备注册
  * @method verify
  * @access public
  * @author NewFuture[newfuture@yunyin.org]
  * @return bool|null
  */
 public function verify($number, $password, $sch_id = null, $code = null)
 {
     $info = array('number' => $number, 'password' => $password, 'sch_id' => $sch_id);
     $code and $info['code'] = $code;
     //验证码
     /*黑名单*/
     $black = isset($this->reg_schools) ? $this->reg_schools : [];
     if (!($result = School::verify($info, $black))) {
         return false;
     } elseif ($result = array_filter($result)) {
         /*验证成功*/
         $reg = array('number' => $info['number'], 'password' => md5($info['password']), 'name' => current($result), 'sch_id' => key($result));
         $sid = Session::start();
         Session::set('reg', $reg);
         unset($reg['password']);
         $reg['school'] = SchoolModel::getName($reg['sch_id']);
         $this->response(2, ['sid' => $sid, 'user' => $reg, 'msg' => '验证成功', 'url' => '/user/']);
         return true;
     }
 }