Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. Route::post('accountAuth', array('as'=>'accountAuth', 'before'=>'csrf', function(){
  2. if ( Auth::attempt( array( 'username'=>Input::get('username'), 'password'=>Input::get('password') ) ) ){
  3. Return View::make('layouts.account.main');
  4. }
  5. else
  6. return Redirect::route('userLogin')
  7. ->with('message','ERROR')
  8. ->withInput();
  9. }));
  10.  
  11. class LogonController extends Controller {
  12.  
  13. public function adminLogin()
  14. {
  15. return $this->login('Admin');
  16. }
  17.  
  18. public function accountLogin()
  19. {
  20. return $this->login('User');
  21. }
  22.  
  23. public function login($model)
  24. {
  25. if ($user = $model::where('username', Input::get('username'))->first())
  26. {
  27. if (Hash::check($user->password, Input::get('password')))
  28. {
  29. Auth::login($user);
  30.  
  31. return Redirect::to('/');
  32. }
  33. else
  34. {
  35. return Redirect::back()->withMessage('Wrong password.');
  36. }
  37. }
  38. else
  39. {
  40. return Redirect::back()->withMessage('User not found.');
  41. }
  42. }
  43.  
  44. }
  45.  
  46. Route::post('admin', 'LogonController@adminLogin');
  47.  
  48. Route::post('login', 'LogonController@accountLogin');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement