Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Add auth redirect path generation method #16896

Merged
merged 1 commit into from
Dec 21, 2016
Merged

[5.3] Add auth redirect path generation method #16896

merged 1 commit into from
Dec 21, 2016

Conversation

antonkomarev
Copy link
Contributor

@antonkomarev antonkomarev commented Dec 21, 2016

Adds call of redirectTo method in Illuminate\Foundation\Auth\RedirectsUsers trait.

It's pretty same as property $this->redirectTo, but if we will have method - there would be an ability to write custom redirect logic after authentication, registration or password reset. For example we can resolve where user should be redirected by using retrieved data from user data, session, cookies, etc...

If there is no redirectTo() method exists in your controller - redirectTo property will be used.

I thought about name of the method. Just left same as property. Another one was: resolveRedirectTo().

@antonkomarev antonkomarev changed the title Add auth redirect path generation method [5.3] Add auth redirect path generation method Dec 21, 2016
@taylorotwell taylorotwell merged commit 794b260 into laravel:5.3 Dec 21, 2016
@antonkomarev antonkomarev deleted the feature/dynamic-redirect-path branch December 21, 2016 15:49
@antonkomarev
Copy link
Contributor Author

Documentation added.

@tortuetorche
Copy link
Contributor

tortuetorche commented Jan 23, 2017

This new feature broke my ControllerAdditions::redirectTo() method with a Missing argument 1 for App\Http\Controllers\Controller::redirectTo() Exception...
I'm going to fix it.

@tortuetorche
Copy link
Contributor

tortuetorche commented Jan 23, 2017

FYI, here my workaround:
To keep backward compatibility, in my App\Http\Controllers\Auth\LoginController class, I replace the redirectTo() call to redirectUserTo().

//...
class LoginController extends Controller
{
    //...

    /**
     * Get the post register / login redirect path.
     * And keep Efficiently\JqueryLaravel\ControllerAdditions::redirectTo()
     *
     * @see https://github.com/efficiently/jquery-laravel/issues/1
     * @return string
     */
    public function redirectPath()
    {
        if (method_exists($this, 'redirectUserTo')) {
            return $this->redirectUserTo();
        }
        return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home';
    }
}

So my ControllerAdditions::redirectTo() method works again 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants