Skip to content
This repository has been archived by the owner on Jan 20, 2021. It is now read-only.

Able to browse to /login while already logged in #19

Open
edtownend opened this issue Apr 14, 2016 · 1 comment
Open

Able to browse to /login while already logged in #19

edtownend opened this issue Apr 14, 2016 · 1 comment

Comments

@edtownend
Copy link

It appears that it is possible to view the login page when already logged in. I'm using the default /login slug, I've disabled all other plugins and rebuilt the permalinks and the problem seems to persist.

As a result of this, if you get the password wrong at the first attempt, then log in correctly, I was redirected back to the login page so it looked like I still wasn't logged in, but I was in fact.

@edtownend
Copy link
Author

edtownend commented Apr 15, 2016

As a temporary workaround I wrote the below.

function dm2_fix_login_issue(){
    if (
        in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ))
        && ! (isset($_REQUEST['action']) || $_REQUEST['action'] == 'logout')
        && is_user_logged_in()
    ) {
        wp_redirect( home_url() );
        exit;
    }
}

add_action('init', 'dm2_fix_login_issue');

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

No branches or pull requests

1 participant