Protect user settings from being access by other users

Posted 9 months ago by AO-IO


I made this middleware to protect "user settings " from being access by other auth users.

   public function handle($request, Closure $next)
         if ($request->slug != auth()->user()->slug) {
            return redirect()->to('/');
        return $next($request);

And I'm using vueJs to update the profile

I managed to get the slug to pass it to my url :

Route::put('/profile/{slug}','[email protected]');

I used props to get my slug.

so the problem is when I ever use this route it says 401 or 500 error in the console:.

am I doing this wrong?

how I can solve this problem so VUEJS can match the request URL with the auth user (Like in the middleware)?

Please sign in or create an account to participate in this conversation.