public function doLogin() { // validate the info, create rules for the inputs $rules = array('username' => 'required', 'password' => 'required|alphaNum|min:6'); // run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules); // if the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::to('login')->withErrors($validator)->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form } else { // create our user data for the authentication $userdata = array('username' => Input::get('username'), 'password' => Input::get('password'), 'active' => 1); // attempt to do the login if (Auth::attempt($userdata, true)) { // validation successful! // redirect them to the secure section or whatever // Auth::user()->role; if (Auth::user()->isAdmin()) { return Redirect::to(Auth::user()->roleString() . '/dashboard'); } else { $htmltree = MemberAPI::getmemberchilds(Auth::user()->id); return Redirect::to(Auth::user()->roleString() . '/dashboard')->with('htmltree', $htmltree); } } else { // validation not successful, send back to form return Redirect::to('login')->withErrors('Email atau password yang Anda berikan salah, mohon mencoba kembali.'); } } }