Skip to content

Debug login from frontend#53

Merged
michaelryanmcneill merged 3 commits intomichaelryanmcneill:masterfrom
Alhrath:master
Aug 19, 2019
Merged

Debug login from frontend#53
michaelryanmcneill merged 3 commits intomichaelryanmcneill:masterfrom
Alhrath:master

Conversation

@Alhrath
Copy link

@Alhrath Alhrath commented Aug 16, 2018

Here is a general fix to take into account the situation where the login form is displayed outside the login page, for instance when a theme display a login form in a menu or as a widget.

@michaelryanmcneill
Copy link
Owner

I would like to get @jrchamp's thoughts on this before approving this PR.

@jrchamp
Copy link
Collaborator

jrchamp commented Mar 22, 2019

I've done some testing on a single site and it's definitely a better experience to have a working login link with an appropriate return_to. However, because $wp->request is null on the normal login page, the experience was worse. I found this to be better (overriding the URL only when it was available):

    global $wp;
    $url = false;
    if ( isset( $wp->request ) ) {
        $url = wp_login_url( home_url( $wp->request ) );
    }
    $login_url = add_query_arg( 'action', 'shibboleth', $url );

I'll take a look at the experience on multisite and follow up. EDIT: Working as expected. Not sure what else to test.

Copy link
Collaborator

@jrchamp jrchamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to this so that admin deeplinks with an auth redirect continue to work:

    global $wp;
    $url = false;
    if ( isset( $wp->request ) ) {
        $url = wp_login_url( home_url( $wp->request ) );
    }
    $login_url = add_query_arg( 'action', 'shibboleth', $url );

@Alhrath
Copy link
Author

Alhrath commented Mar 28, 2019

Ok like this ?

@jrchamp
Copy link
Collaborator

jrchamp commented Mar 28, 2019

Yes, mostly. There shouldn't be any spaces used to indent, because WordPress uses tabs to indent.

Sorry, I know my comment uses spaces because the github comment box doesn't make adding tabs easy.

Copy link
Collaborator

@jrchamp jrchamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

To summarize this change: Improve the Shibboleth login link so that when it shows up on a normal request it will correctly still be a login link and will redirect back to the page that showed the login link.

Prior to this change: Shibboleth login links created by this code when on any page other than wp-login.php do not work because they just append action=shibboleth to the request URL.

@michaelryanmcneill
Copy link
Owner

This looks good to me. Merging.

@michaelryanmcneill michaelryanmcneill merged commit a7ccb3e into michaelryanmcneill:master Aug 19, 2019
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

Comments