Skip to content

extend authenticator methods #210

Answered by sergiodxa
rodbs asked this question in Q&A
Dec 18, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

You own the session storage, this means you can store anything in the session and grab it as usual in Remix

async function isSubscribed(request: Request) {
  let session = await sessionStorage.getSession(request.headers.get("cookie"))
  let isSubscribed = session.get("isSubscribed")
  if (typeof isSubscribed === "boolean") return isSubscribed
  return false;
}

export async function loader({ request }: LoaderArgs) {
  if (await isSubscribed(request)) {
    // do something
  } else {
    // do something else
  }
}

Another option is to store that data in the value returned by the strategy verify callback, then you can use the isAuthenticated method.

export async function loader({ request }: 

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@rodbs
Comment options

@sergiodxa
Comment options

@rodbs
Comment options

Answer selected by rodbs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants