コード例 #1
0
ファイル: AuthController.php プロジェクト: nattaphat/cuse2
 public function loginAction()
 {
     Input::flash();
     //$data = Input::all();
     $data = array('username' => Input::get('username'), 'password' => Input::get('password'));
     // 'min:3' ensures that the value is greater than or equal to the parameter provided
     // 'max:32' ensure that the value is less than or equql to the parameter provided
     $rules = array('username' => array('min:4', 'max:16', 'required'), 'password' => array('required', 'alpha_num'));
     $messages = array('username.required' => 'กรุณาระบุชื่อผู้ใช้งาน', 'username.min' => 'ชื่อผู้ใช้งานจะต้องยาวกว่า :min ตัวอักษร', 'password.required' => 'กรุณาระบุรหัสผ่าน');
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         $usernhc = Usernhc::where('username', '=', $data['username'])->first(array('status', 'grp_id'));
         if (isset($usernhc) && $usernhc->status == 'yes') {
             if (Auth::attempt($data)) {
                 //Redirect to secure area.
                 return Redirect::to('admin')->with('success', 'เข้าสู่ระบบสำเร็จ');
                 //->with(array('success'=>'Yor have logged in successfully','grp_id'=>$usernhc->grp_id));
             } else {
                 //Redirect to the login page.
                 return Redirect::to('login')->withErrors(array('password' => 'รหัสผ่านไม่ถูกต้อง'));
             }
         } else {
             return Redirect::to('login')->withErrors(array('status' => 'ท่านยังไม่ได้ลงทะเบียนหรือยังไม่ได้รับอนุญาตให้เข้าสู่ระบบ'));
         }
     }
     //Something went wrong.
     return Redirect::to('login')->withErrors($validator)->withInput(Input::except('password'));
 }
コード例 #2
0
ファイル: Usernhc.php プロジェクト: nattaphat/cuse2
 /**
  * [getUserIdByUserName description]
  * @param  [type] $username [description]
  * @return [type]           [description]
  */
 public function getUserIdByUserName($username)
 {
     $rs = Usernhc::where('username', '=', $username)->get(array('id'));
     return $rs[0]['id'];
 }
コード例 #3
0
ファイル: UsernhcController.php プロジェクト: nattaphat/cuse2
 /**
  * [getUserIdByUserName description]
  * @param  [type] $username [description]
  * @return [type]           [description]
  */
 public static function getUserIdByUserName($username)
 {
     $userid = Usernhc::where('username', '=', $username)->get(array('id'));
     return $userid[0]->id;
 }