로그인한 후 리다이렉트 되는 URL 변경하기

Submitted by river - 등록 8 years ago - 수정 8 years ago

Laravel은 로그인이 성공한 뒤 /home 으로 라다이렉트한다. 이를 다른 URL로 변경하려면 AuthController$redirectPath 속성을 추가해서 지정하면 된다.

App\Http\Controllers\Auth\AuthController

namespace App\Http\Controllers\Auth;

use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

class AuthController extends Controller
{
    protected $redirectPath = '/';

    ...
}

관련 로직은 RedirectUers trait에 있다.

Illuminate\Foundation\Auth\RedirectsUsers


<?php namespace Illuminate\Foundation\Auth; trait RedirectsUsers { /** * Get the post register / login redirect path. * * @return string */ public function redirectPath() { if (property_exists($this, 'redirectPath')) { return $this->redirectPath; } return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home'; } }
comments powered by Disqus