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

User::authenticated() returning true despite "Provided token does not exist." #1

Closed
seifip opened this issue Jun 13, 2014 · 4 comments
Assignees
Labels

Comments

@seifip
Copy link

seifip commented Jun 13, 2014

There seem to be issues with User::authenticated(), possibly related to userapp-io/userapp-angular#6

Every once in a while, quite randomly, User::authenticated() starts returning true yet when I try to access any of the user properties throws exception 'UserApp\Exceptions\ServiceException' with message 'Unable to authenticate as user. Provided token does not exist.'

The only fix is to clear cache & cookies, refresh and relogin.

@seifip
Copy link
Author

seifip commented Jun 13, 2014

ex.:

if(User::authenticated()){
    try{
        $user = User::current();
        if($user->hasPermission("admin")){
            echo("User is admin!\n");
        }
        echo $user->email;
    }
    catch(Exception $e){
        echo $e;
    }
}

sometimes starts throwing:

exception 'UserApp\Exceptions\ServiceException' with message 'Unable to authenticate as user. Provided token does not exist.' in

@typerandom
Copy link
Contributor

This issue occurs when the local session thinks that it's logged in, but the remote session has expired. That is why it might occur random. I'm sorry for the inconvenience. Will start working on a fix.

@typerandom
Copy link
Contributor

The latest version that I have pushed should resolve this issue. This version also adds support for listening to client events. So my recommendation is that you listen to the event 'unauthorized', and if the user is not authorized, you can just redirect them to your login page.

The following should work:

User::onUnauthorized(function($sender, $call_context, $error){
    header("Location: /login.php");
    die();
});

Let me know how this works for you :-)

Cheers!

Robin

@typerandom typerandom self-assigned this Jun 21, 2014
@typerandom typerandom added the bug label Jun 21, 2014
@typerandom
Copy link
Contributor

Closing this issue since there has been no response in a week and a bug fix has been issued that should resolve the issue.

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

No branches or pull requests

2 participants