Every time I click to go to another page, ask for the login again (LARAVEL 5.6)

Asked

Viewed 69 times

0

Good afternoon, everyone

Every time I go to another page my application asks to redo the login

Follows route

Route::get('/', function () {
    return view('welcome');
});



Auth::routes();

Route::group(['prefix'=>'admin','middleware'=>'auth'], function(){

    Route::get('/create', 'CreateController@create')->name('create');
    Route::get('/query', 'CreateController@query')->name('query');
    Route::get('/detalhes', ['as'=>'detalhes', 'uses'=> 'CreateController@detalhes']);
    Route::get('/tarefas', ['as'=>'tarefas', 'uses'=> 'CreateController@tarefas']);
    Route::post('/store', ['as'=>'store', 'uses'=> 'CreateController@store']);
    Route::post('/delete', ['as' => 'delete' , 'uses' => 'CreateController@delete']);
    Route::post('/alterar', ['as' => 'alterar' , 'uses' => 'CreateController@alterar']);
    Route::post('/update', ['as' => 'update' , 'uses' => 'CreateController@update']);

});

Route::get('/home', 'HomeController@index')->name('home');

Home controller:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * CreateController a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('home');
    }
}

I do not know specifically where the problem is yet, if you need more information forward

  • 2

    You are using middleware auth on all routes, this middleware makes all routes accessible only with logged in user.

  • So, this is the intention, that access is provided only to logged in users, the point is that if I am on the HOME page and click to go on the CREATE page it redirects me to the LOGIN page, however, I was already logged in.

  • Use this in your controller: echo '<pre>'; print_r( auth()->user() ); die; .

  • @Kayobruno Amigo already managed to solve the problem, it was a very basic thing,in one of my views was passing in a href={{ Auth::Logout() }}, and every time I reloaded the page this method was called, but thank you very much for the help :)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.