-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Added signinInfo
when signing in
#7234
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ import type { | |
ResponseInternal, | ||
} from "../types.js" | ||
|
||
const SIGNIN_INFO_MAX_AGE = 60 * 15 // 15 minutes in seconds | ||
|
||
/** @internal */ | ||
export async function AuthInternal< | ||
Body extends string | Record<string, any> | any[] | ||
|
@@ -139,6 +141,18 @@ export async function AuthInternal< | |
} else { | ||
switch (action) { | ||
case "signin": | ||
if (request.body?.signinInfo !== undefined) { | ||
const expires = new Date() | ||
expires.setTime(expires.getTime() + SIGNIN_INFO_MAX_AGE * 1000) | ||
cookies.push({ | ||
name: options.cookies.signinInfo.name, | ||
value: request.body.signinInfo, | ||
options: { | ||
...options.cookies.signinInfo.options, | ||
expires, | ||
}, | ||
}) | ||
} | ||
Comment on lines
+144
to
+155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Absolutely no idea if this is the right place to put it... but it works! |
||
if ((csrfDisabled || options.csrfTokenVerified) && options.provider) { | ||
const signin = await routes.signin( | ||
request.query, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,8 @@ export interface CallbacksOptions<P = Profile, A = Account> { | |
} | ||
/** If Credentials provider is used, it contains the user credentials */ | ||
credentials?: Record<string, CredentialInput> | ||
/** Info from the client's `signIn()` function. */ | ||
signinInfo?: SigninInfo | ||
}) => Awaitable<boolean> | ||
/** | ||
* This callback is called anytime the user is redirected to a callback URL (e.g. on signin or signout). | ||
|
@@ -237,9 +239,12 @@ export interface CookiesOptions { | |
csrfToken: CookieOption | ||
pkceCodeVerifier: CookieOption | ||
state: CookieOption | ||
signinInfo: CookieOption | ||
nonce: CookieOption | ||
} | ||
|
||
export type SigninInfo = string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it |
||
|
||
/** | ||
* The various event callbacks you can register for from next-auth | ||
* | ||
|
@@ -269,7 +274,7 @@ export interface EventCallbacks { | |
| { session: Awaited<ReturnType<Required<Adapter>["deleteSession"]>> } | ||
| { token: Awaited<ReturnType<JWTOptions["decode"]>> } | ||
) => Awaitable<void> | ||
createUser: (message: { user: User }) => Awaitable<void> | ||
createUser: (message: { user: User, signinInfo?: SigninInfo }) => Awaitable<void> | ||
updateUser: (message: { user: User }) => Awaitable<void> | ||
linkAccount: (message: { | ||
user: User | AdapterUser | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add it as an optional param so it may be extended in the future with other data. Also shouldn't break exiting adapters.