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

Inject repository in oauth provider #2541

Closed
DatGuyJonathan opened this issue Mar 5, 2019 · 16 comments · Fixed by #2872
Closed

Inject repository in oauth provider #2541

DatGuyJonathan opened this issue Mar 5, 2019 · 16 comments · Fixed by #2872
Assignees

Comments

@DatGuyJonathan
Copy link

DatGuyJonathan commented Mar 5, 2019

Description / Steps to reproduce / Feature proposal

I'm trying to use a couple of repositories in an oauth2 flow. The setup is similar to #1835 where I have a verify function that I want to try calling the repositories. The error is:

Error: The key repositories.UserInfoRepository was not bound to any value

The organization and user models have a has-many/belongs-to relation so creating a user with the org repository is supposed to invoke the user repository. I followed https://loopback.io/doc/en/lb4/HasMany-relation.html to setup the models & repos. I think I have the repositories and models wired up correctly because I can move the logic into a controller and it works fine.

Any ideas what I need to bind/inject?

export class MyAuthenticationProvider
  implements Provider<PassportAuthenticationStrategy> {
  constructor(
    @repository(OrganizationRepository)
    private organizationRepository: OrganizationRepository,
    @inject(SecretBindings.SECRET_SERVICE)
    private secretService: SecretService
  ) {}

  public value(): ValueOrPromise<PassportAuthenticationStrategy> {
    const callbackURL = process.env.DNS_NAME
      ? process.env.DNS_NAME
      : 'http://localhost:3000';
    const clientID = process.env.CLIENT_ID
      ? process.env.CLIENT_ID
      : 'CLIENT_ID_TEST';
    const clientSecret = process.env.CLIENT_SECRET
      ? process.env.CLIENT_SECRET
      : 'CLIENT_SECRET_TEST';
    return new MyOAuth2Strategy(
      {
        authorizationURL:
          '<insert auth url>',
        tokenURL: '<insert token url>,
        clientID,
        clientSecret,
        callbackURL: `${callbackURL}/auth/callback`
      },
      this.verify.bind(this)
    );
  }

  private async verify(
    accessToken: string,
    refreshToken: string,
    user: UserInfo,
    callback: VerifyCallback
  ): Promise<void> {
    if (accessToken && refreshToken) {
      user.refreshToken = refreshToken;

      await this.organizationRepository.create({
        id: user.organizationId
      });

      user.token = await this.secretService.encrypt(accessToken);
      user.refreshToken = await this.secretService.encrypt(user.refreshToken);
      await this.organizationRepository.users(user.organizationId).create(user); // THE ERROR IS HERE
      return callback(null, user);
    }
    return callback(new Error('Invalid tokens'), user);
  }
}
@raymondfeng
Copy link
Contributor

Which class expects to inject repositories.UserInfoRepository?

@DatGuyJonathan
Copy link
Author

@raymondfeng , my OrganizationRepository ctor looks like this:

constructor(
    @inject('datasources.db') dataSource: DbDataSource,
    @repository.getter('UserInfoRepository')
    getUserInfoRepository: Getter<UserInfoRepository>
  ) {
    super(Organization, dataSource);
    this.users = this.createHasManyRepositoryFactoryFor(
      'users',
      getUserInfoRepository
    );
  }

@raymondfeng
Copy link
Contributor

Can u upgrade to latest version of loopback? We recently fixed a similar issue. Let’s make sure.

@DatGuyJonathan
Copy link
Author

I tried the latest and still saw the issue. Here are my deps:

yarn list v1.10.1
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ @loopback/[email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]

@raymondfeng
Copy link
Contributor

Do you have UserInfoRepository bound to the context? For example, in src/repositories folder?

@DatGuyJonathan
Copy link
Author

That's a good question. I do have it in src/repositories, and I also have these in application.ts (not sure if I need all these):

export class ApiServerApplication extends BootMixin(
  ServiceMixin(RepositoryMixin(RestApplication))
) {
  constructor(options: ApplicationConfig = {}) {
    super(options);
    ...
    ...
    this.repository(OrganizationRepository);
    this.repository(UserInfoRepository);
    ...
    ...
    this.bootOptions = {
      controllers: {
        dirs: ['controllers'],
        extensions: ['.controller.js', '.controller.ts'],
        nested: true
      },
      repositories: {
        dirs: ['repositories'],
        extensions: ['.repository.js', '.repository.ts'],
        nested: true
      },
      datasources: {
        dirs: ['datasources'],
        extensions: ['.datasource.js', '.datasource.ts'],
        nested: true
      }
    };
  }
}

@raymondfeng
Copy link
Contributor

Can you run the app with DEBUG=loopback:context env var to see what's failing?

@raymondfeng
Copy link
Contributor

You don't have to call this.repository(UserInfoRepository); if UserInfoRepository is in src/repositories and app.boot() is called.

@DatGuyJonathan
Copy link
Author

Here are the logs. The only thing that sticks out to me is
loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] Closing context... +1ms right before the error. Is that the right thing to hone in on? How do I get more info on it?

  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [application.instance] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [application.config] Adding binding: +2ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [components.RestComponent] Adding binding: +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.RestComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.sequence] Adding binding: +2ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.apiSpec] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.sequence.actions.logError] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.sequence.actions.findRoute] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.sequence.actions.invokeMethod] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.sequence.actions.reject] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [bindElement] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [getFromContext] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.sequence.actions.parseParams] Adding binding: +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.sequence.actions.send] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.requestBodyParser] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.requestBodyParser.JsonBodyParser] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.requestBodyParser.TextBodyParser] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.requestBodyParser.UrlEncodedBodyParser] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.requestBodyParser.RawBodyParser] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.requestBodyParser.StreamBodyParser] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [servers.RestServer] Adding binding: +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.RestComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.RestComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.RestComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [components.BootComponent] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.BootComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [application.bootstrapper] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.BootComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.BootComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.BootComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [booters.ApplicationMetadataBooter] Adding binding: +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [booters.ControllerBooter] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [booters.RepositoryBooter] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [booters.ServiceBooter] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [booters.DataSourceBooter] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [boot.project_root] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [boot.options] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest.sequence] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: servers.RestServer +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [rest.port] Adding binding: +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [rest.host] Adding binding: +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [rest.protocol] Adding binding: +1ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [rest.httpsOptions] Adding binding: +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [rest.basePath] Adding binding: +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [rest.handler] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [rest-explorer.config] Adding binding: +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [components.RestExplorerComponent] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.RestExplorerComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: servers.RestServer +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [routes.get %2Fexplorer] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: servers.RestServer +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [routes.get %2Fexplorer%2F] Adding binding: +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: servers.RestServer +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: servers.RestServer +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.RestExplorerComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.RestExplorerComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: components.RestExplorerComponent +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [datasources.db] Adding binding: +53ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [MY_PROVIDER] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [MY_AUTHENTICATOR] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [services.secret] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [services.secret.key] Adding binding: +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding: application.bootstrapper +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [boot.project_root] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [boot.options] Adding binding: +0ms
  loopback:context [92bb1f30-4032-11e9-8b19-472b939d2baa] Resolving binding: booters.ApplicationMetadataBooter +2ms
  loopback:context [92bb1f30-4032-11e9-8b19-472b939d2baa] Resolving binding: booters.ControllerBooter +1ms
  loopback:context [92bb1f30-4032-11e9-8b19-472b939d2baa] Resolving binding: booters.RepositoryBooter +0ms
  loopback:context [92bb1f30-4032-11e9-8b19-472b939d2baa] Resolving binding: booters.ServiceBooter +0ms
  loopback:context [92bb1f30-4032-11e9-8b19-472b939d2baa] Resolving binding: booters.DataSourceBooter +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [controllers.MyAuthenticationController] Adding binding: +28ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [controllers.LogoutController] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [controllers.PingController] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [controllers.TestController] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [controllers.WorkspaceController] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [repositories.OrganizationRepository] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [repositories.UserInfoRepository] Adding binding: +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [repositories.WorkspaceRepository] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] [datasources.db] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding: repositories.OrganizationRepository +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding: repositories.UserInfoRepository +7ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding: repositories.WorkspaceRepository +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding: datasources.db +1ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding: servers.RestServer +51ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: rest.router +3ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: routes.get %2Fexplorer +6ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: routes.get %2Fexplorer%2F +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: rest.apiSpec +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] Resolving binding: rest.port +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] Resolving binding: rest.host +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] Resolving binding: rest.protocol +1ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] Resolving binding: rest.httpsOptions +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [rest.port] Adding binding: +2ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [rest.host] Adding binding: +0ms
  loopback:context [92b21e80-4032-11e9-8b19-472b939d2baa] [rest.url] Adding binding: +0ms
  loopback:context [92b0e600-4032-11e9-8b19-472b939d2baa] Resolving binding synchronously: servers.RestServer +0ms
Server is running at http://127.0.0.1:3000
Try http://127.0.0.1:3000/ping
  loopback:context [95cf15f0-4032-11e9-8b19-472b939d2baa] [rest.http.request] Adding binding: +5s
  loopback:context [95cf15f0-4032-11e9-8b19-472b939d2baa] [rest.http.response] Adding binding: +0ms
  loopback:context [95cf15f0-4032-11e9-8b19-472b939d2baa] [rest.http.request.context] Adding binding: +0ms
  loopback:context [95cf15f0-4032-11e9-8b19-472b939d2baa] Resolving binding: rest.sequence +1ms
  loopback:context [95cf15f0-4032-11e9-8b19-472b939d2baa] Closing context... +12ms
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] [rest.http.request] Adding binding: +1s
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] [rest.http.response] Adding binding: +0ms
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] [rest.http.request.context] Adding binding: +0ms
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] Resolving binding: rest.sequence +0ms
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] [controller.current] Adding binding: +1ms
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] [controller.current.ctor] Adding binding: +0ms
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] [controller.current.operation] Adding binding: +0ms
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] Resolving binding: controller.current +1ms
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] Resolving binding: controllers.MyAuthenticationController +0ms
  loopback:context [96767980-4032-11e9-8b19-472b939d2baa] Closing context... +4ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] [rest.http.request] Adding binding: +8s
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] [rest.http.response] Adding binding: +1ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] [rest.http.request.context] Adding binding: +0ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] Resolving binding: rest.sequence +0ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] [controller.current] Adding binding: +1ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] [controller.current.ctor] Adding binding: +0ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] [controller.current.operation] Adding binding: +0ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] Resolving binding: controller.current +0ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] Resolving binding: controllers.MyAuthenticationController +1ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] Closing context... +19ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] [rest.http.request] Adding binding: +1ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] [rest.http.response] Adding binding: +1ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] [rest.http.request.context] Adding binding: +0ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] Resolving binding: rest.sequence +0ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] [controller.current] Adding binding: +0ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] [controller.current.ctor] Adding binding: +0ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] [controller.current.operation] Adding binding: +0ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] Resolving binding: controller.current +0ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] Resolving binding: controllers.WorkspaceController +0ms
  loopback:context [9af746b0-4032-11e9-8b19-472b939d2baa] Closing context... +1ms
  loopback:context [9af3c440-4032-11e9-8b19-472b939d2baa] Resolving binding: repositories.UserInfoRepository +1s
(node:58366) UnhandledPromiseRejectionWarning: Error: The key repositories.UserInfoRepository was not bound to any value.
    at RequestContext.getBinding (/node_modules/@loopback/context/dist/context.js:493:15)
    at RequestContext.getValueOrPromise (/node_modules/@loopback/context/dist/context.js:528:30)
    at RequestContext.get (/node_modules/@loopback/context/dist/context.js:471:27)
    at DefaultHasManyRepository.getter [as getTargetRepository] (/node_modules/@loopback/context/dist/inject.js:171:20)
    at DefaultHasManyRepository.create (/node_modules/@loopback/repository/dist/relations/has-many/has-many.repository.js:20:45)
    at serializeUser (/packages/api-server/lib/providers/authentication/myAuthenticator.js:53:22)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:58366) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:58366) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@raymondfeng
Copy link
Contributor

This is interesting. We close the request context using on-finished after the http response is done. Passport seems to invoke the serializeUser afterward. Maybe the request context is closed too early? We might have to call close at https://github.com/strongloop/loopback-next/blob/master/packages/rest/src/http-handler.ts#L79 instead.

@raymondfeng
Copy link
Contributor

@DatGuyJonathan Do you want to try to run close() in process.nextTick or setImmediate/setTimeout at https://github.com/strongloop/loopback-next/blob/master/packages/rest/src/request-context.ts#L25 to see if it helps?

@DatGuyJonathan
Copy link
Author

Thanks for the suggestion @raymondfeng . setImmediate didn't work, but setTimeout worked. Having a timeout seems like it would be flaky though. But I think we've confirmed that the problem is that RequestContext is closed too early in my auth flow.

Could there be an event instead that I can trigger to close the request when I'm ready?

@raymondfeng
Copy link
Contributor

I don't find an event that fits your scenario. I think the key is to find out when Passport finishes the callback. Is it possible to create a sandbox app to reproduce the problem? If so, I can help troubleshoot.

@raymondfeng
Copy link
Contributor

IMO, passport framework should finishes serializeUser before the http response is finished. Otherwise, the client side might get a positive response even when serializeUser fails.

@coolirisroto
Copy link

I had the same problem? how can we fixed! ? Regards.

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

Successfully merging a pull request may close this issue.

3 participants