Answer the question
In order to leave comments, you need to log in
How is authentication implemented correctly?
I'm trying to implement authentication with and without the remember me function.
I implement it without the standard Auth::attempt($credentials, $remember)
logic. If the user has checked the remember me checkbox, I create a cookie for a while and write it to the hashing database.
Every time during routes, through middleware I check the identity of the cookie and the hash of the database entry.
If everything is ok, I skip it.
If the user does not put remember me, how to bypass the middleware to check for cookies?
If an additional condition in the middleware is to write a check whether the user is authorized
if (Auth::check()) {
return $next($request);
}
Answer the question
In order to leave comments, you need to log in
Every time during routes, through middleware I check the identity of the cookie and the hash of the database entry.
If everything is ok, I skip it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question