php - 如何更改 Laravel 5 中的默认登录 URL?

标签 php laravel laravel-5.1

我在我的项目中使用模块

App -> 
   Modules ->
      Admin -> 
          Http ->
              controller
              middleware
              request

我如何在此中间件中使用身份验证和重定向身份验证文件 在此中间件中验证文件或重定向验证文件

验证.php

public function handle($request, Closure $next)
    {
        if ($this->auth->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                // return redirect()->guest('auth/login');
                return redirect()->guest('admin');
            }
        }

        return $next($request);
    }

redirectauthenticate.php

 public function handle($request, Closure $next)
    {
        if ($this->auth->check()) {
            // return redirect('/home');
            return redirect('admin/dashbord');
        }

        return $next($request);
    }

如何解决这个问题?

最佳答案

docs 中所示:

When a user is not successfully authenticated, they will be redirected to the /auth/login URI. You can customize the failed post-authentication redirect location by defining a loginPath property on the AuthController:

protected $loginPath = '/login';

在您的情况下,您将使用 '/admin' 而不是 '/login'

关于php - 如何更改 Laravel 5 中的默认登录 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34040432/

相关文章:

laravel - 如何使用 Sentinel 执行 actingAs()

php - 始终如一地将随机字符串更改为颜色

php - 在有限的托管环境中使用 Blade 模板

mysql - 在 laravel 5.1 注册期间将 IP 地址存储在数据库中

laravel - 随着时间的推移,使用 Laravel 部分重构旧的大型 PHP 应用程序?

php - 从 url laravel 中删除部分段

php - Laravel Associate 方法在 View 中返回空数组

php - 如何使用 PHP 验证 SPF 记录

php - 如何在 Laravel 中求和嵌套关系属性?

php - 我的自定义 get_the_excerpt() 无法通过 ID 获取摘录