コード例 #1
0
 public function dologin()
 {
     $params = Input::all();
     if (empty($params['username'])) {
         Session::flash('error', '用户名必须填写');
         return Redirect::route('login');
     }
     if (empty($params['password'])) {
         Session::flash('error', '密码必须填写');
         return Redirect::route('login');
     }
     if (empty($params['captcha'])) {
         Session::flash('error', '验证码必须填写');
         return Redirect::route('login');
     }
     if (!$this->_validate_captcha($params['captcha'])) {
         Session::flash('error', '验证码错误');
         return Redirect::route('login');
     }
     $password = md5(md5($params['password']));
     $admin = AdminORM::whereUsername($params['username'])->wherePwd($password)->where('status', '<>', BaseORM::DISABLE)->first();
     if (!empty($admin)) {
         Session::flash('success', '登陆成功');
         $admin_id_cookie = Cookie::forever('admin_id', $admin->id);
         $admin_username_cookie = Cookie::forever('admin_username', $admin->username);
         $k_cookie = Cookie::forever('k', Crypt::encrypt($admin->id . $admin->username));
         $login_time_cookie = Cookie::forever('login_time', time());
         $admin->last_login_time = date('Y-m-d H:i:s');
         $admin->save();
         return Redirect::route('home')->withCookie($k_cookie)->withCookie($admin_id_cookie)->withCookie($admin_username_cookie)->withCookie($login_time_cookie);
     } else {
         Session::flash('error', '用户没找到');
         return Redirect::route('login');
     }
 }
コード例 #2
0
 private function _check($params)
 {
     $msg = '';
     if (empty($params['username'])) {
         $msg = '用户名必须填写';
     }
     $admin = AdminORM::whereUsername($params['username'])->first();
     if (isset($params['currentpwd'])) {
         $password = md5(md5($params['currentpwd']));
         if ($password != $admin->pwd) {
             $msg = '当前密码不正确';
         }
         if ($params['pwd'] != $params['confirmpwd']) {
             $msg = '两次密码填写不一致';
         }
     }
     if (!empty($admin) && $params['id'] == 0) {
         $msg = '用户名重复';
     }
     return $msg;
 }