Skip to content

Commit

Permalink
Merge pull request #550 from pokt-foundation/portalUserID
Browse files Browse the repository at this point in the history
Auth: !PortalUserID
  • Loading branch information
RabeeAbuBaker authored Dec 5, 2023
2 parents 9b83d53 + 20b42ec commit ab6bc54
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/utils/user.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export enum Permissions {

export const requireUser = async (request: Request, defaultRedirect = "/") => {
const url = new URL(request.url)
const user = await authenticator.isAuthenticated(request)
let user = await authenticator.isAuthenticated(request)

if (!user) {
throw redirect("/api/auth/auth0")
Expand All @@ -25,6 +25,10 @@ export const requireUser = async (request: Request, defaultRedirect = "/") => {
throw await authenticator.logout(request, { redirectTo: "/email-verification" })
}

if (!user.user.portalUserID) {
user = await authenticator.authenticate("auth0", request)
}

const decode = jwt_decode<{
exp: number
}>(user.accessToken)
Expand Down

0 comments on commit ab6bc54

Please sign in to comment.