You should really take several weeks to thoroughly learn this stuff, before going into production. In some cases it would not hurt to take a few months. Work examples in the docs and watch some videos on authentication and authorization.
Jul 12, 2018
2
Level 1
my laravel accounts has become mixed
I have created a laravel application where the users are normal users and admin users... i login both of them to the website via the default laravel authentication... and i have middleware to hide some routes from normal users. but now i have a big problem... some times when i refresh the page I find my self in antoher account (example: now i am johne, refresh the page and i find my self jasmine)! .. i didn't face such a problem before :( , that problem now is rarely happen... I host now my application in a shared hosting.
/* RoleMiddlware.php */
public function handle($request, Closure $next,$role)
{
// $roles :
// 0: user
// 1: admin
if(\Auth::user()['role'] != $role) return redirect('/');
return $next($request);
}
// in web.php i use the middlewate like this:
Route::get(...)->middleware('role:1');
Please or to participate in this conversation.