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

[Feature Request] - Redirect login page if already logged in #2249

Closed
ClaraLeigh opened this issue Apr 14, 2015 · 11 comments
Closed

[Feature Request] - Redirect login page if already logged in #2249

ClaraLeigh opened this issue Apr 14, 2015 · 11 comments
Labels
Product Areas:Authentication & Login Status:Available Reviewed issue, it’s real, we’d review a pull request. Type:Enhancement A need for something new.

Comments

@ClaraLeigh
Copy link

Hey,

Is there a reason the login page doesn't redirect you if you're already logged in?
I can't think of a reason why we shouldn't redirect already logged in users.

Seems like a fairly easy thing to do seeing there is already a "ChooseRedirect" function inside the login controller.

Anyway, this would be my suggestion.

File: /web/concrete/controllers/single_page/login.php

public function view($type = null, $element = 'form')
    {
        // Do default redirect if already logged in
        $u = new User();
        if ($u->isRegistered()) {
            $this->chooseRedirect();
        }

        $this->requireAsset('javascript', 'backstretch');
        $this->set('authTypeParams', $this->getSets());
        if (strlen($type)) {
            $at = AuthenticationType::getByHandle($type);
            $this->set('authType', $at);
            $this->set('authTypeElement', $element);
        }
    }
@joe-meyer
Copy link
Contributor

I agree that this should redirect, or give a 403 permission denied error (and indicate that you're already logged in).

@Remo
Copy link
Contributor

Remo commented Apr 15, 2015

seeing that codes makes we wonder what's the difference between isLoggedIn and isRegistered, but yeah I agree with this change.

@joe-meyer
Copy link
Contributor

seeing that codes makes we wonder what's the difference between isLoggedIn and isRegistered, but yeah I agree with this change.

isRegistered isn't a static function and simply checks that the uID is greater than 0 on the object, whereas isLoggedIn is a static function and checks the $_SESSION for some user information.

@Remo
Copy link
Contributor

Remo commented Apr 15, 2015

Well, this I understand, but why do we need both? isRegistered is also a bit strange because if I fetch another user object (!= current user) and then call isRegistered I get true which kind of obvious but also useless..

@joe-meyer
Copy link
Contributor

Well that's not entirely true. If you attempt to fetch a user object that doesn't exist in the database for instance then this would return false. Also, you'd probably want to make sure that the user isActive as well as registered.

Ultimately I would think we would want to get away from using the current implementation of the isLoggedIn method since it's dependent on sessions and makes stateless applications difficult. As an example, if I wanted to implement a REST API that used auth keys on each requests, I wouldn't want to be depending on those sessions to exist, I would want to have my request instantiate my user object, and then check if it is logged in by checking that user's properties.

@Remo
Copy link
Contributor

Remo commented Apr 15, 2015

Of course, there are a few edge cases like that, just wanted to point out that those method might need some attention, didn't want to hijack this issue..

@aembler
Copy link
Member

aembler commented Apr 16, 2015

I think the sad answer is just duplicate crusty code. I think we'd want to keep isRegistered() and alias isLoggedIn() over to isRegistered() (setting aside any concerns about how isRegistered() actually populates its own data – it should be the canonical, proper method.)

@aembler
Copy link
Member

aembler commented Apr 16, 2015

Seems like a good addition

@Mnkras
Copy link
Contributor

Mnkras commented Apr 16, 2015

Another thing, the login page could technically be an editable page, to edit it, you need to be able to get to that page...

@KorvinSzanto
Copy link
Member

I have a working branch somewhere that shows "log out" as an option if
you're logged in, I'd like to see if I can dig that up before we merge
this.

On Wed, Apr 15, 2015, 8:46 PM Andrew Embler notifications@github.com
wrote:

Seems like a good addition


Reply to this email directly or view it on GitHub
#2249 (comment)
.

@aembler
Copy link
Member

aembler commented Jan 8, 2020

We are going to update this page so that the authentication types don't show up when you're logged in - you just get a logout button. This should allow you to still edit the content on the page.

@aembler aembler added Product Areas:Authentication & Login Status:Available Reviewed issue, it’s real, we’d review a pull request. Type:Enhancement A need for something new. and removed Recategorize:Discussion labels Jan 8, 2020
@aembler aembler closed this as completed Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product Areas:Authentication & Login Status:Available Reviewed issue, it’s real, we’d review a pull request. Type:Enhancement A need for something new.
Projects
None yet
Development

No branches or pull requests

6 participants