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

Allow to block authorization depending on whether it is a new user or not #8272

Open
GermanJablo opened this issue Aug 9, 2023 · 4 comments · May be fixed by #8478
Open

Allow to block authorization depending on whether it is a new user or not #8272

GermanJablo opened this issue Aug 9, 2023 · 4 comments · May be fixed by #8478
Labels
enhancement New feature or request

Comments

@GermanJablo
Copy link

GermanJablo commented Aug 9, 2023

Description 📓

Problem

Currently, there is no easy and direct way to intervene in the authorization flow based on whether the user is new (signup) or not (login).

A user has proposed to verify some property that is not in both situations, but I don't know how reliable it is. Does it work in all circumstances? For all providers? Also, it's not self-evident or something that follows from the documentation. A user a few comments above in the same thread proposed a similar alternative, which ended up not working. As you can see, it is a workaround that is prone to errors.

Possible solutions:

  1. Bring the isNewUser property also to the signIn callback (as requested here).
  2. Allow events to block the authorization flow in some way (return boolean, throw error, etc.).
  3. Extend next-auth to have signup and login as different processes. This would likely involve, but not necessarily be limited to:
    3.1. Add a new Signup callback (as requested here).
    3.2. Add a new Signup function (as requested here).

The third point is probably the hardest to implement and the one that would add the most complexity. I don't know to what extent it would be wrong since users and programmers actually think of creation and login as different concepts. Still, I think I lean more toward options 1 and 2.

In option 2, the events would end up being essentially the same as the callbacks.
Option 1, on the other hand, would be to add for an event, its corresponding callback that does not exist yet. Which would make the event technically unnecessary.
I wonder if actually "events" was a good abstraction and not just a few more callbacks should have been defined.

Background - Related References

The large number of posts, comments, and upvotes in the login vs signup topic indicate that this is something that users are frequently stumbling upon. Some examples:

How to reproduce ☕️

N/A

Contributing 🙌🏽

No, I am afraid I cannot help regarding this

@GermanJablo GermanJablo added enhancement New feature or request triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Aug 9, 2023
@kahveciderin kahveciderin linked a pull request Sep 3, 2023 that will close this issue
3 tasks
@kahveciderin
Copy link

I saw this issue yesterday and thought maybe I could contribute, so I've created a PR that hopefully fixes this.

@ThangHuuVu ThangHuuVu removed the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Sep 6, 2023
Copy link

stale bot commented Feb 11, 2024

It looks like this issue did not receive any activity for 60 days. It will be closed in 7 days if no further activity occurs. If you think your issue is still relevant, commenting will keep it open. Thanks!

@stale stale bot added the stale Did not receive any activity for 60 days label Feb 11, 2024
@GermanJablo

This comment has been minimized.

@stale stale bot removed the stale Did not receive any activity for 60 days label Feb 12, 2024
@thclark
Copy link

thclark commented May 3, 2024

Massive upvote on this. I'm new to next-auth and am finding it to be really very well polished, so I'm very grateful!

However, this area of signup vs signin seems so massively, massively complicated when it should be simple!

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

Successfully merging a pull request may close this issue.

4 participants