Answer the question
In order to leave comments, you need to log in
How to redirect user before rendering laravel layer in vue?
Hello!
I have routes like this in laravel:
Route::get('/admin{any}',function(){
return view('admin');
})->where('any','.*');
Route::get('/{any}',function(){
return view('index');
})->where('any','.*');
if (to.matched.some(record => record.meta.isAdmin)) {
if (store.getters['auth/role']!="admin") {
return redirect({name:'Error403'});
}
}
if ($request->user()->role=="admin"){
return $next($request);
}
else
{
return response(['message'=>"Недостаточно прав для посещения данного ресурса"],403);
}
Route::get('/admin{any}',function(){
return view('admin');
})->where('any','.*')->middleware('isAdmin');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question