Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User is serialized but the type doesn't express that #273

Open
lifeiscontent opened this issue Mar 17, 2024 · 0 comments
Open

User is serialized but the type doesn't express that #273

lifeiscontent opened this issue Mar 17, 2024 · 0 comments

Comments

@lifeiscontent
Copy link
Contributor

Describe the bug

when using methods like isAuthenticated it doesn't return a User but rather a SerializeFrom<User> e.g. if you try to return a record with a bigint it'll serialize to a string

I'm not sure if this has something to do with how the cookie storage works or if this is a bug in remix-auth but just ran into this issue where the verify function return value was complaining that the type of user had string values but prisma was returning bigint

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

type User = {
  id: string
}

function getUser(): {id: bigint } {
  return {id: new BigInt(1) }
}

export const authenticator = new Authenticator<User>(sessionStorage);

assert(process.env.GOOGLE_CLIENT_ID, 'GOOGLE_CLIENT_ID is not set');
assert(process.env.GOOGLE_CLIENT_SECRET, 'GOOGLE_CLIENT_SECRET is not set');

authenticator.use(
  new GoogleOAuth2Strategy(
    {
      callbackURL: `/auth/google/callback`,
      clientID: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET,
      responseType: 'code',
      accessType: 'offline',
      scope:
        'openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email',
    },
    async ({ profile }) => {
       return getUser() // this complains because it returns bigints rather than string
                                   // but the return value will always be strings during consumption in loaders/actions
    },
  ),
  'google',
);

Expected behavior

proper type handling

Screenshots or Videos

No response

Platform

  • OS: MacOS
  • Browser: Chrome
  • Version: N/A

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant