Laravel Конечные точки входа в систему несколько раз при входе в систему - PullRequest
0 голосов
/ 17 февраля 2020

У меня есть основной домен, который является зарегистрированным. laravel .com, где пользователь может зарегистрировать свой домен по своему выбору, например: foo здесь

При успешной регистрации пользователь может посетить foo.laravel.com, который подключается к определенной c базе данных, которую я обработал в Middleware. Работает правильно, так как я могу отобразить foo. laravel .com и увидеть нужную базу данных, к которой он подключен.

Теперь, когда пользователь входит в систему, пользователи получают

This page isn’t working foo.laravel.com redirected you too many times.

Журналы доступа выглядят следующим образом

127.0.0.1 - - [18/Feb/2020:00:07:45 +0530] "GET /login HTTP/1.1" 200 1384 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "POST /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:48 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:49 +0530] "GET /login HTTP/1.1" 302 374 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [18/Feb/2020:00:07:49 +0530] "GET / HTTP/1.1" 302 398 "http://foo.laravel.com/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"

Как я вижу, когда пользователь входит в систему, он перенаправляет на /, затем пытается перенаправить его обратно на «вход», я не уверен откуда он идет.

У меня есть два файла. php, которые я изменяю в RouteServiceProvider.php в зависимости от домена, который выглядит так:

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to your controller routes.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * The path to the "home" route for your application.
     *
     * @var string
     */
    public const HOME = '/';

    /**
     * The path to the "register success" route for your application.
     *
     * @var string
     */
    public const RegisterSuccess = '/register/success';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        //

        parent::boot();
    }

    /**
     * Define the routes for the application.
     *
     * @return void
     */
    public function map()
    {
        $this->mapApiRoutes();

        $this->mapWebRoutes();

        //
    }

    /**
     * check the domain, if it is register then register the routes
     * else move to erp application
     * @return array
     */
    private function checkDomain()
    {
        $domain = config('app.domain');

        if (request()->getHttpHost() === 'register.'.$domain) {
            return ['domain' => 'register.'.$domain, 'routeFile' => 'routes/register.php', 'middleware' => ['web']];
        }

        return ['domain' => request()->getHttpHost(), 'routeFile' => 'routes/web.php', 'middleware' => ['web','domainVerification', 'connectTenant']];
    }


    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
    protected function mapWebRoutes()
    {

        $data = $this->checkDomain();

        Route::domain($data['domain'])
            ->middleware($data['middleware'])
            ->namespace($this->namespace)
            ->group(base_path($data['routeFile']));
    }
}

регистрация. php для регистрация. laravel .com

<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// Registration Routes...
Route::get('/', 'Auth\RegisterController@showRegistrationForm')->name('registerForm');
Route::post('/register', 'Auth\RegisterController@register')->name('register');
Route::get('register/success', 'Auth\RegisterController@success');

web. php для домена пользователя ex: foo. laravel .com

Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
Route::get('/logout', 'Auth\LoginController@logout')->name('logout');


Route::group(['middleware' => 'auth'], function () {

    Password Reset Routes...
    Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
    Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
    Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
    Route::post('password/reset', 'Auth\ResetPasswordController@reset');

    Route::get('/', 'HomeController@index')->name('home');

});

Может ли кто-нибудь помочь мне с этой проблемой? Дайте мне знать, если вам нужно больше деталей.

...