important
This is a contributors guide and NOT a user guide. Please visit these docs if you are using or evaluating SuperTokens.
Add flowContext arg to shouldDoAutomaticAccountLinking
- Status:
- accepted
- Deciders:
- rishabhpoddar, bhumilsarvaiya
- Proposed by:
- rishabhpoddar
- Created:
- 2022-12-01
Context and Problem Statement#
Developers may want to control when automatic accout linking can happen. For example, they may want that in the sign up API, but not in the password reset API.
So how can we allow them to control this?
Considered Options#
- Add an extra argument to the function called
flowContextwhich will contain info about the context. - Not to provide any such context and keeps thing simple
- Implement this using canLinkAccount and canCreatePrimaryUser functions
- Use
sessioncontainer object as one of the args for the function
Decision Outcome#
Option chosen: Add an extra argument to the function called flowContext which will contain info about the context.
The type of flowContext is:
flowContext: {
fromAPI: "RESET_PASSWORD" | "LINK_ACCOUNT_TO_EXISTING_ACCOUNT"
willNewUserBeCreated: boolean,
willUserIdChangeOfExistingUser: boolean
} | {
fromAPI: "SIGN_UP"
} | {
fromAPI: "EMAIL_VERIFICATION",
willUserIdChangeOfExistingUser: boolean
}
By default, we API for post login account linking will use this argument to return shouldRequireVerification as false.