Exemplo n.º 1
0
 public function login()
 {
     $validator = validator::make([input::get('account'), input::get('password')], ['required', 'required'], ['请输入账号!', '请输入密码!']);
     if ($validator->fails()) {
         $messages = $validator->messagesInfo();
         foreach ($messages as $error) {
             return $this->splash('error', null, $error[0]);
         }
     }
     $verifycode = input::get('verifycode');
     if (userAuth::isShowVcode('login')) {
         if (!input::get('key') || empty($verifycode) || !base_vcode::verify(input::get('key'), $verifycode)) {
             $msg = app::get('topc')->_('验证码填写错误');
             return $this->splash('error', $url, $msg, true);
         }
     }
     try {
         if (userAuth::attempt(input::get('account'), input::get('password'))) {
             $url = input::get('next_page');
             return $this->splash('success', $url, $msg, true);
         }
     } catch (Exception $e) {
         userAuth::setAttemptNumber();
         if (userAuth::isShowVcode('login')) {
             $url = url::action('topc_ctl_passport@signin');
         }
         $msg = $e->getMessage();
         return $this->splash('error', $url, $msg, true);
     }
 }
Exemplo n.º 2
0
 public function login()
 {
     $verifycode = input::get('verifycode');
     if (userAuth::isShowVcode('login')) {
         if (!input::get('key') || empty($verifycode) || !base_vcode::verify(input::get('key'), $verifycode)) {
             $msg = app::get('topm')->_('验证码填写错误');
             return $this->splash('error', $url, $msg, true);
         }
     }
     try {
         if (userAuth::attempt(input::get('account'), input::get('password'))) {
             $url = $this->__getFromUrl();
             return $this->splash('success', $url, $msg, true);
         }
     } catch (Exception $e) {
         userAuth::setAttemptNumber();
         if (userAuth::isShowVcode('login')) {
             $url = url::action('topm_ctl_passport@signin');
         }
         $msg = $e->getMessage();
         return $this->splash('error', $url, $msg, true);
     }
 }