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

signIn callback does not follow NextAuth API and is not called. #85

Open
FunMiles opened this issue Apr 27, 2022 · 1 comment
Open

signIn callback does not follow NextAuth API and is not called. #85

FunMiles opened this issue Apr 27, 2022 · 1 comment
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@FunMiles
Copy link

I am trying to implement a two step authorization. i.e. use Google/Facebook/name-your-method authentication and then check the associated email is verified and is in a white list database of authorized emails. It is my understanding that this can be done with NextAuth using the signIn call back.

For sk-auth, the documentation states:

SvelteKitAuth provides some callbacks, similar to NextAuth.js. Their call signatures are:
interface AuthCallbacks {
  signIn?: () => boolean | Promise<boolean>;
  jwt?: (token: JWT, profile?: any) => JWT | Promise<JWT>;
  session?: (token: JWT, session: Session) => Session | Promise<Session>;
  redirect?: (url: string) => string | Promise<string>;
}

NextAuth has the following interface for signIn:

async signIn({ user, account, profile, email, credentials }) {
     const isAllowedToSignIn = true
    if (isAllowedToSignIn) {
      return true
    } else {
      // Return false to display a default error message
      return false
      // Or you can return a URL to redirect to:
      // return '/unauthorized'
    }
}

Even when I put a signIn() call back, it is never called. Looking for all appearances of signIn in the source code gives this:

sk-auth % grep -rn signIn *      
README.md:71:  signIn?: () => boolean | Promise<boolean>;
src/client/index.ts:1:export { signIn } from "./signIn";
src/client/signIn.ts:10:export async function signIn(provider: string, data?: any, config?: SignInConfig) {
src/auth.ts:21:  signIn?: () => boolean | Promise<boolean>;

Thus it seems signIn is never called. Is that an upcoming upgrade, or is there another method to do what I want to do?

@FunMiles FunMiles changed the title signIn callback does not follow NextAuth APi and is not called. signIn callback does not follow NextAuth API and is not called. Apr 28, 2022
@Dan6erbond Dan6erbond added bug Something isn't working help wanted Extra attention is needed labels May 3, 2022
@Dan6erbond Dan6erbond self-assigned this May 3, 2022
@Dan6erbond
Copy link
Owner

This is a good point. That might have just been a blunder on my part, forgetting to call the method in the auth provider.

To-do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants