Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Using Accounts-base with another DDP connection #12870

@gonzadelarge

Description

@gonzadelarge

https://github.com/meteor/meteor/tree/devel/packages/accounts-base

Captura de pantalla 2023-11-09 101830

Expected behavior: It is expected to allow a user to successfully log in using loginWithToken even even when the users are managed by an external server.

Actual behavior: After manual login, upon refreshing the page, the first try to log in is with loginWithToken using the default connection, causing the app to log out without using the token and forcing the user to manually log in again.

Meteor version: [email protected]
Accounts version: [email protected]

Reproduce the problem:

  1. Attempt to use Accounts-base with an external server managing the users.
  2. Notice _initLocalStorage() is executing before the Meteor.startup of your app starts.
  3. On the first use of the app, one can log in successfully. But upon refreshing the page, the first log-in attempts use the default connection causing a log-out.

Detailed issue:
I am trying to use Accounts-base with an external server that manages the users. The main problem is AUTO LOGIN _initLocalStorage because this executes before my app starts. This means when _initLocalStorage executes and calls loginWithToken, Accounts use Meteor's standard DDP and default users collection to search for the user and token on the main server of the app, instead of external server, and then I'll never be able to do loginWithToken because the users are in another collection in the external server.

Error message: "Error logging in with token: Error: You've been logged out by the server. Please log in again. [403]

Somethings that I've already tried

  • Accounts allows to create an Accounts Instance for multi-server, but I have the same problem because AccountsClient is executed before my application started, also, Accounts provides different methods for login, but loginWithPassword belongs to accounts-password, and if I try to use the multi-server option, I will never be able to use both methods (loginWithPassword, loginWithToken) because one of them is using the application server and the other its external server with their respective collections.
  • I could find that the config method in accounts_common.js allows to configure the package from Meteor.settings but I could not do it by any way (Set global accounts options. You can also set these in Meteor.settings.packages.accounts without the need to call this function).
  • If I apply the ddpUrl option manually on the package in the AccountsClient constructor, the package behavior is correct and everything is fine.

Captura de pantalla 2023-11-09 105748

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions