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

For a custom auth integration with Dexie cloud, how does one initiate a login from a server after user info has been collected? #2060

Open
andersr opened this issue Aug 22, 2024 · 1 comment

Comments

@andersr
Copy link

andersr commented Aug 22, 2024

(I posted this in discussions, but reposting here, as I'm not clear what the correct place is to post questions.)

I am currently looking at adding a custom auth integration and reviewing the example provided in the docs.

Based on the example, it appears the only way to initiate a login flow in Dexie Cloud is from the client, by calling db.cloud.login({ email: "[email protected]"}) which then results in a call from dexie cloud to the endpoint added in fetchTokens in cloud.config.

However, based on the provided example, it appears that the server needs to respond immediately to this call with a token, which does not allow for completion of a custom login flow. (Eg an OTP roundtrip.)

It seems there needs to be a "/login" endpoint that is equivalent to calling db.cloud.login({ email: "[email protected]"}), but allows a server to do so after the needed info (eg their email) has been collected in a custom flow. Or am I not understanding how this should work?

Any clarifications would be appreciated!

@dfahlander
Copy link
Collaborator

sorry for late reply. Even if the fetchTokens callback expects a Promise of a TokenResponse in return, there's nothing requiring this to be returned immediately. You can implement any custom flow of multiple requests/responses between your client and server before returning a result. You could even redirect the user away from your app to a 3rd part login flow using oidconnect or similar (in that case there won't be any TokenResponse returned but it doesn't matter because the login flow would reddirect you back to your app when completed and att that time, you'd have a local endpoint that will have login information immediately this time.

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

2 participants