public function doLogin() { $in = Input::all(); $user = array('AccountID' => $in['AccountID'], 'password' => $in['password']); $rules = array('AccountID' => 'Required|min:7|max:7', 'password' => 'Required|min:6|max:20'); $validator = Validator::make($user, $rules); if ($validator->passes()) { $check = User::where('StudentID', $in['AccountID'])->where('lastSeen', '>=', date_sub(date_create(MyDate::getNormalDateFormat()), date_interval_create_from_date_string("1 minute")))->first(); if (!count($check)) { $user = array('StudentID' => $in['AccountID'], 'password' => $in['password']); if (Auth::attempt($user)) { User::updateLastSeen(); User::addLoginRecord(); return Redirect::to('/'); } else { return Redirect::back()->withErrors(array('password' => 'Account ID and Password not matched'))->withInput(Input::except('password')); } } else { return Redirect::back()->withErrors(array('password' => 'Your account is currently online. Multiple login session is not allowed.'))->withInput(Input::except('password')); } } return Redirect::back()->withErrors($validator)->withInput(Input::except('password')); }