Laravel 5 - After login redirect back to previous page

前端 未结 13 2339
广开言路
广开言路 2020-11-30 04:41

I have a page with a some content on it and a comments section. Comments can only be left by users who are signed in so I have added a login form to the page for users to si

13条回答
  •  佛祖请我去吃肉
    2020-11-30 05:12

    For Laravel 5.5, following code worked for me by just updating LoginController.php

    public function showLoginForm()
    {
        session(['link' => url()->previous()]);
        return view('auth.login');
    }
    
    
    protected function authenticated(Request $request, $user)
    {
        return redirect(session('link'));
    }
    

提交回复
热议问题