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

Check if user is logged in #150

Open
popeating opened this issue Mar 6, 2022 · 2 comments
Open

Check if user is logged in #150

popeating opened this issue Mar 6, 2022 · 2 comments

Comments

@popeating
Copy link

Is there an endpoint, that based on jwt (or refresh token) tell me if im logged n?

im actually using the user query with my usename and jwt, but it feel quiete unsecure, i mean i can pass any username registered on the system

i would prefere an endpoint like /me that return the current user/owner of jwt

thank you

@ojohnny
Copy link

ojohnny commented Mar 26, 2022

The endpoint you are looking for is called viewer, which returns information about the currently logged in user, no need to specify any username at all. viewer is null if you are not logged in.

Something as simple as this will do:

query Viewer {
  viewer {
    id
  }
}

...but of course you can get more user information from the same object if you want, such as username, email, avatar or the current auth and refresh tokens.

query Viewer {
  viewer {
    avatar {
      url
    }
    email
    username
    jwtAuthToken
    jwtRefreshToken
  }
}

@Khadreal
Copy link

The endpoint you are looking for is called viewer, which returns information about the currently logged in user, no need to specify any username at all. viewer is null if you are not logged in.

Something as simple as this will do:

query Viewer {
  viewer {
    id
  }
}

...but of course you can get more user information from the same object if you want, such as username, email, avatar or the current auth and refresh tokens.

query Viewer {
  viewer {
    avatar {
      url
    }
    email
    username
    jwtAuthToken
    jwtRefreshToken
  }
}

I tried querying the viewer endpoint to get jwtRefreshToken but getting Cannot query field \"jwtRefreshToken\" on type \"User\". error

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

3 participants