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

$session->forceLogin does not update $user variable #3

Closed
ivangretsky opened this issue Sep 7, 2016 · 3 comments
Closed

$session->forceLogin does not update $user variable #3

ivangretsky opened this issue Sep 7, 2016 · 3 comments

Comments

@ivangretsky
Copy link

ivangretsky commented Sep 7, 2016

After using $session->forceLogin($loginUser) the $user variable does not get updated before the page reload. But wire('user') function returns what is needed. It seems a little inconsistent. Is it supposed to be that way, or is it a bug?

@LostKobrakai
Copy link
Contributor

LostKobrakai commented Sep 7, 2016

Local variables cannot be updated. They are declared like you would do it for your variables before the template files are included. They then refer to the object assigned to it. wire() on the other hand is a function, which does lookup the current user object each time it's called. One could create a wrapper object to assign to $user, which does the same, but that's probably not worth the effort for such a small usecase. It's probably best to redirect after forceLogin anyways.

@ivangretsky
Copy link
Author

ivangretsky commented Sep 7, 2016

Ok, understood. As forceLogin() returns a User object or null, it is possible to do something like that:

$fl = $session->forceLogin($loginUser);
if ($fl) {
    $user = $fl;
}

@LostKobrakai
Copy link
Contributor

Sure. There's nothing special about those variables.

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

No branches or pull requests

2 participants