Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Support previous session in callbacks #2988

Closed
lavcraft opened this issue Oct 20, 2021 · 3 comments
Closed

Support previous session in callbacks #2988

lavcraft opened this issue Oct 20, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@lavcraft
Copy link

Description πŸ““

Provide current session variable in callbacks for access information stored in session and merge into new.

It's useful in cases, when you need to get some tokens from multiple service for provide integration. For example β€” you need to create documents in sharepoint and attach it to google calendars. In this case, i need in one time and one place two tokens β€” from google and from azure.

This ability in callbacks is very useful for cover case above, and accumulate all user accounts (with different emails in place, when i confident about this merge (but if it main flow for authenticated user, like "attach google account" - why not?)

According to Discussion about handling current session β€” it's not so hard to implement feature :)

How to reproduce β˜•οΈ

For examples usage (see current* args):

        jwt: async (
            newToken: JWT,
            user?: User,
            account?: Account,
            profile?: Profile,
            isNewUser?: boolean,
            currentToken?: JWT
        )  = { ... }

Or

session: async (
            newSession: Session,
            userOrToken: JWT | User,
            oldSession: Session,
        ) => {..}

Contributing πŸ™ŒπŸ½

Yes, I am willing to help implement this feature in a PR

@lavcraft lavcraft added the enhancement New feature or request label Oct 20, 2021
@dbeaudway
Copy link

@lavcraft, I'm very interested in this feature and have seen other discussion posts asking for the same. Any progress here -- willing to pitch in if you have a branch.

@balazsorban44
Copy link
Member

Related: #3116 (reply in thread)

@stale stale bot added the stale Did not receive any activity for 60 days label Jan 10, 2022
@nextauthjs nextauthjs deleted a comment from stale bot Jan 10, 2022
@balazsorban44 balazsorban44 removed the stale Did not receive any activity for 60 days label Jan 17, 2022
@lavcraft
Copy link
Author

@balazsorban44 thanks. It's related, but not similar one. In this case, we don't need multiple sessions info in stateless token. Only need current session during authenticating process for merging.

For example:

  1. Login via google (email1)
  2. Login via azure (email2) while authorized from step 1. In signIn or session callback i can resolve current session and construct new session with derived roles. Also - can write new email (email2 from azure) to user info in database (may spawn additional dialog for user, like do you want attach this account to your user?)

@nextauthjs nextauthjs locked and limited conversation to collaborators Feb 12, 2022
@balazsorban44 balazsorban44 converted this issue into discussion #3946 Feb 12, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants