Novice question: my app has two user types (i.e., ...
# prisma-whats-new
j
Novice question: my app has two user types (i.e.,
manager
,
associate
), and I have a separate single-page React app for each user type (i.e.,
manager app
,
associate app
). For a serverless architecture using JWT for authentication (e.g., Graphcool & Auth0), 1) where does the logic to check for authentication reside (i.e., check if user authenticated; if not, redirect to /login page) and 2) where does the logic to determine which app to load reside (i.e., if user is authenticated, check userType in JWT and load either
manager
app or
associate
app? Any help is much appreciated!
n
@jesse thanks for your questions! 1) you can check if a user is authenticated using the user query:
Copy code
query {
  # is null for wrong or no JWT in authorization header
  user {
    id
  }
}
now in your app you would need to run this query, and depending on the result redirect to /login 2) the information would not reside inside the JWT, but rather on the user node in your Graphcool project. So a user could have a role, that would either be
MANAGER
or
ASSOCIATE
. the role can once again be queried using the user query:
Copy code
query {
  user {
    id
    role
  }
}
j
Thanks @nilan! It seems like I need to load an app prior making that call though (i.e., can't be done when user navigates to endpoint without loading a front-end app). The
manager app
and
associate app
are different though (and in different repos, entirely). Is your suggestion to have a higher-level
auth app
that does this check and then loads the correct functional app (i.e.,
manager app
vs
associate app
), if
auth = true
and
userType = manager | associate
? Thanks again!
n
Yea you would need some kind of check before that, indeed
j
👍
Thanks so much!
n
Sure! 🙂 Let me know how it goes