dongxixia6399 2016-11-02 14:54
浏览 24
已采纳

作者会话的Laravel Change Redirect部分到期

When the session expires my users are getting redirected to /login however they should be redirected to /backoffice/login, does anyone know in which file I can change the redirection part?

  • 写回答

1条回答 默认 最新

  • dongroufan6846 2016-11-02 15:16
    关注

    Your Exception Handler is what takes all unauthenticated requests and handles them in the way you need.

    It will look something like this:

    app/Exceptions/Handler.php

    /**
     * Convert an authentication exception into an unauthenticated response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Illuminate\Auth\AuthenticationException  $exception
     * @return \Illuminate\Http\Response
     */
    protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }
    
        return redirect()->guest('login');
    }
    

    You can adjust the redirect by changing return redirect()->guest('login'); to return redirect()->guest('backoffice/login');

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?