mardi 1 septembre 2015

Laravel after login all routes not found

I'm working on laravel project and for public user every thing works fine with no issue, but once the user logged all page become inaccessible and I get 404 page not found even for public page.
If I delete the cookies public page become accessible again.

This is my login function :

 try{
            if (Auth::validate($userdata)) {
                if (Auth::attempt($userdata)) {
                    // TODO check if is admin Role
                    $user = Auth::user()->getParseUser();
                    if ($user->get('isAdmin'))
                        return Redirect::intended('/');
                    else {
                        Auth::logout(); // logout user
                        return Redirect::back()->with('error', "Access denied");
                    }
                }
            } else {
                // if any error send back with message.
                return Redirect::back()->with('error', 'invalid login parameters ');
            }
        } catch (ParseException  $ex) {
            // if any error send back with message.
            if ($ex->getCode() == 101)
                return Redirect::back()->with('error', 'invalid login parameters');
            else
                return Redirect::back()->with('error', 'Please contact the admin');
        }

Route file :

Route::get('/', 'PublicController@index');

Route::get('/product/{id}','PublicController@details');

Route::get('login', 'PublicController@login');
Route::post('login', 'PublicController@loginAction');

Route::get('logout', function(){
    Auth::logout(); // logout user
    return Redirect::to('/');
});


Route::delete('product/{id}', ['middleware' => 'auth', 'uses' =>'AnnounceController@destroy']);
Route::delete('product/comment/{id}', ['middleware' => 'auth', 'uses' =>'AnnounceController@destroyComment']);



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1VtdeAY
via IFTTT

Aucun commentaire:

Enregistrer un commentaire