[Solved] Basic Sanity Checks Failed

I’ve a Redwood & Supabase (with Supabase auth) project going and every once in a while my users (& now me) are presented w/this:

Screen Shot 2021-06-18 at 7.30.31 AM

my users have tried refreshing/logging out&in again/thrashing about – clears the problem

is this how I know a users’ token is expired?

what could/should I see/test and do to stop this from happening?

@ajoslin103 That “sanity” check code is use the the Playground Auth as a basic validation helper – it should not be in your app code.

ok, I can get with that

but what is it telling me?

The code for that component is here: playground-auth/AuthResults.js at c9fd0b3320577e3cb2ad97ce312b1d56b2f0f55f · redwoodjs/playground-auth · GitHub

  const { type, userMetadata, currentUser, isAuthenticated } = useAuth()
  const typeOk = type && type === currentUser?.type
  const emailOk = /^\w+@\w+.*\.\w\w+$/.test(userMetadata?.email)
  const tokenOk = currentUser?.token && currentUser?.token !== 'null'

// ...

 <>
          <h3>Basic sanity checks</h3>
          <ul>
            <li style={{ color: typeOk ? 'green' : 'red' }}>Correct type</li>
            <li style={{ color: emailOk ? 'green' : 'red' }}>Valid email</li>
            <li style={{ color: tokenOk ? 'green' : 'red' }}>Token !== null</li>
          </ul>
        </>

@Tobbe added these checks some time ago to make sure that the useAuth() returned sensible info and a check against some regressions:

  • there’s some sort of email in userMetadata
  • the type is the expected type (in playground this was important b/c it tests multiple providers)
  • there’s a token

But that was help helpful when the test page had all the providers on a single page.

It isn’t as applicable now.

See thee discussion here for the background: Discussion: Sanity checks · Issue #56 · redwoodjs/playground-auth · GitHub

When I updated the Supabase auth implementation some months ago I accidentally introduced some regression, can’t even remember now. But, to not risk doing the same thing next time I (or someone else) updated a provider I added the “Basic sanity checks”. It made it easy to scan the list of all the providers and see that all the checks still passed.

Now that all the providers are on different pages and, on each page, the checks are scrolled out of view, I’m starting to question the value of the checks.

1 Like