Laravel: Form display and logic in single route

When I need to create some sort of form in laravel I use a single route for both form displaying and saving. For that reason I need to use Route::any('login', 'LoginController@login') which doesn’t feel right.

For example my typical login form controller method:

public function login()
    // handle submit
        if(Auth::attempt(array('username' => Input::get('username'), 'password' => Input::get('password'))))
            return Redirect::intended('profile');
        } else {
            return Redirect::back()->withInput()
                ->withErrors(['auth-validation' => 'Invalid username or password']);

    // show form
    $this->layout->content = View::make('frontend/login');

The question is: are there any security risks of Route::any or anything other I cannot think of in the long run?

Source: laravel

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.