ProjectProtege / protege

Remote jobs for junior developers
protege.vercel.app
MIT License
67 stars 39 forks source link

fix - protected routes no longer get sent to sign-in if valid user #318

Closed clandau closed 3 years ago

clandau commented 3 years ago

Description

What does this PR do?

  1. Code to check whether a company has all required info in their account was getting set too soon, and in the case of a user pressing the back button, the profileInfo returned null, throwing an error.

    • Here I changed the check to a function, and called it within the rendered HTML, which is working. Also I check whether profileInfo exists and if not, return false.
  2. Routing to /thanks after payment sent the user back to sign-in. This was happening when verifyIdToken would throw an expired token error. AuthContext updates an expired token when getIdToken is called. If we don't throw on expired token, it works itself out.

    • here I changed the verifyIdToken method to not throw the error if the token is expired. There are other ways we could do this, but this is nice and simple and works. I'm happy to discuss alternate solutions if anyone wants.

Related Tickets and Documents

What gif best describes this PR or how it makes you feel? (optional)

vercel[bot] commented 3 years ago

Someone is attempting to deploy a commit to a Personal Account owned by @drewclem on Vercel.

@drewclem first needs to authorize it.

clandau commented 3 years ago

I'm pretty sure this fixes the error with the ID token expiring too, haven't been able to recreate it since and it's now refreshing automatically as it should in AuthContext when getIdToken is called.

Edit - doesn't fix the routing to sign-in. Still working