Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Route::post('accountAuth', array('as'=>'accountAuth', 'before'=>'csrf', function(){
- if ( Auth::attempt( array( 'username'=>Input::get('username'), 'password'=>Input::get('password') ) ) ){
- Return View::make('layouts.account.main');
- }
- else
- return Redirect::route('userLogin')
- ->with('message','ERROR')
- ->withInput();
- }));
- class LogonController extends Controller {
- public function adminLogin()
- {
- return $this->login('Admin');
- }
- public function accountLogin()
- {
- return $this->login('User');
- }
- public function login($model)
- {
- if ($user = $model::where('username', Input::get('username'))->first())
- {
- if (Hash::check($user->password, Input::get('password')))
- {
- Auth::login($user);
- return Redirect::to('/');
- }
- else
- {
- return Redirect::back()->withMessage('Wrong password.');
- }
- }
- else
- {
- return Redirect::back()->withMessage('User not found.');
- }
- }
- }
- Route::post('admin', 'LogonController@adminLogin');
- Route::post('login', 'LogonController@accountLogin');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement