0

I'm trying to use auth middleware within my controller at construct method with except argument and it does not working.

I created my controller with artisan command and its contains methods like create, edit, show, etc.

here is my construct:

public function __construct()
{
    $this->middleware('auth', ['except' => ['index', 'show']]);
}

if i visit some methods like edit and create when i'm not logged in middleware does not works and i can see the content. i also tried only instead of except, same result.

Ravexina
  • 2,406
  • 2
  • 25
  • 41

2 Answers2

0

did you change Authenticate.php for auth middleware this function

public function handle($request, Closure $next)
{
}
Imtiaz Pabel
  • 5,307
  • 1
  • 19
  • 24
0

I figure out that problem was with my addressing/

i had except index and show at my construct and i was trying to access the edit method with /controller/edit which is wrong, because controller assume the edit part as an index method argument, so i changed the url to /controller/1/edit and it's working.

it was my bad, cause i used Codeigniter for a long time, sometimes i still think that i'm working with Ci.

Ravexina
  • 2,406
  • 2
  • 25
  • 41