Skip to content

Commit 922338a

Browse files
committed
add authType
1 parent 40d02e8 commit 922338a

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

examples/apple.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const appleOAuth = OAuth2Plugin({
8585
throw error;
8686
}
8787
},
88-
successRedirect: (req) => {
88+
successRedirect: (req: PayloadRequest, token?: string) => {
8989
// Check user roles to determine redirect
9090
const user = req.user;
9191
if (user && Array.isArray(user.roles)) {

examples/google.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const googleOAuth = OAuth2Plugin({
5959

6060
return token;
6161
},
62-
successRedirect: (req) => {
62+
successRedirect: (req: PayloadRequest, accessToken?: string) => {
6363
return "/admin";
6464
},
6565
failureRedirect: (req, err) => {

examples/zitadel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const zitadelOAuth = OAuth2Plugin({
6363

6464
return token;
6565
},
66-
successRedirect: (req) => {
66+
successRedirect: (req: PayloadRequest, token?: string) => {
6767
return "/admin";
6868
},
6969
failureRedirect: (req, err) => {

src/authorize-endpoint.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const createAuthorizeEndpoint = (
1111
const authCollection = pluginOptions.authCollection || "users";
1212
const callbackPath = pluginOptions.callbackPath || "/oauth/callback";
1313
const redirectUri = `${pluginOptions.serverURL}/api/${authCollection}${callbackPath}`;
14-
const scope = pluginOptions.scopes.join(" ");
1514

15+
const scope = pluginOptions.scopes.join(" ");
1616
const responseType = "code";
1717
const accessType = "offline";
1818

@@ -30,6 +30,9 @@ export const createAuthorizeEndpoint = (
3030
if (pluginOptions.responseMode) {
3131
url.searchParams.append("response_mode", pluginOptions.responseMode);
3232
}
33+
if (pluginOptions.authType) {
34+
url.searchParams.append("auth_type", pluginOptions.authType);
35+
}
3336

3437
return Response.redirect(url.toString());
3538
},

src/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ export interface PluginTypes {
139139
*/
140140
prompt?: string;
141141

142+
/**
143+
* Authentication type for the OAuth provider.
144+
* This is used by Facebook to specify the behavior of login flow.
145+
* Reference: https://developers.facebook.com/docs/facebook-login/guides/advanced/re-authentication/
146+
* Possible values are "reauthenticate" and "rerequest".
147+
*/
148+
authType?: string;
149+
142150
/**
143151
* Path to the callback endpoint.
144152
* Must start with a forward slash.
@@ -165,6 +173,7 @@ export interface PluginTypes {
165173
* @deprecated Use the two-parameter overload instead
166174
*/
167175
successRedirect(req: PayloadRequest): string | Promise<string>;
176+
168177
/**
169178
* Redirect users after successful login.
170179
* @param req PayloadRequest object

0 commit comments

Comments
 (0)