Skip to content

Commit f0b54df

Browse files
committed
feat: support signInOptions from SignInButton component
1 parent 275b244 commit f0b54df

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

packages/nextjs/src/client/components/actions/SignInButton/SignInButton.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ import {useRouter} from 'next/navigation';
2727
/**
2828
* Props interface of {@link SignInButton}
2929
*/
30-
export type SignInButtonProps = BaseSignInButtonProps;
30+
export type SignInButtonProps = BaseSignInButtonProps & {
31+
/**
32+
* Additional parameters to pass to the `authorize` request.
33+
*/
34+
signInOptions?: Record<string, any>;
35+
}
3136

3237
/**
3338
* SignInButton component that uses server actions for authentication in Next.js.
@@ -55,7 +60,7 @@ export type SignInButtonProps = BaseSignInButtonProps;
5560
*/
5661
const SignInButton = forwardRef<HTMLButtonElement, SignInButtonProps>(
5762
(
58-
{className, style, children, preferences, onClick, ...rest}: SignInButtonProps,
63+
{className, style, children, preferences, onClick, signInOptions = {}, ...rest}: SignInButtonProps,
5964
ref: Ref<HTMLButtonElement>,
6065
): ReactElement => {
6166
const {signIn, signInUrl} = useAsgardeo();
@@ -72,7 +77,7 @@ const SignInButton = forwardRef<HTMLButtonElement, SignInButtonProps>(
7277
if (signInUrl) {
7378
router.push(signInUrl);
7479
} else {
75-
await signIn();
80+
await signIn(signInOptions);
7681
}
7782

7883
if (onClick) {

packages/react/src/components/actions/SignInButton/SignInButton.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ import useTranslation from '../../../hooks/useTranslation';
2525
/**
2626
* Props interface of {@link SignInButton}
2727
*/
28-
export type SignInButtonProps = BaseSignInButtonProps;
28+
export type SignInButtonProps = BaseSignInButtonProps & {
29+
/**
30+
* Additional parameters to pass to the `authorize` request.
31+
*/
32+
signInOptions?: Record<string, any>;
33+
};
2934

3035
/**
3136
* SignInButton component that supports both render props and traditional props patterns.
@@ -70,7 +75,7 @@ export type SignInButtonProps = BaseSignInButtonProps;
7075
const SignInButton: ForwardRefExoticComponent<SignInButtonProps & RefAttributes<HTMLButtonElement>> = forwardRef<
7176
HTMLButtonElement,
7277
SignInButtonProps
73-
>(({children, onClick, preferences, ...rest}: SignInButtonProps, ref: Ref<HTMLButtonElement>): ReactElement => {
78+
>(({children, onClick, preferences, signInOptions = {}, ...rest}: SignInButtonProps, ref: Ref<HTMLButtonElement>): ReactElement => {
7479
const {signIn, signInUrl} = useAsgardeo();
7580
const {t} = useTranslation(preferences?.i18n);
7681

@@ -86,7 +91,7 @@ const SignInButton: ForwardRefExoticComponent<SignInButtonProps & RefAttributes<
8691

8792
window.dispatchEvent(new PopStateEvent('popstate', {state: null}));
8893
} else {
89-
await signIn();
94+
await signIn(signInOptions);
9095
}
9196

9297
if (onClick) {

0 commit comments

Comments
 (0)