Skip to content

Commit ba5cb0c

Browse files
committed
Pass through redirectUrlOverride to button creation
1 parent 0cbe5ca commit ba5cb0c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

web/src/ButtonComponents/OAuthButtons.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33
import LinkOAuth from './LinkOAuth'
44
import LoginWithOAuth from './LoginWithOAuth'
55
import SignupWithOAuth from './SignupWithOAuth'
6-
import { FTGetOAuthUrls } from '../oauth'
6+
import { FTGetOAuthUrls, IGetOAuthUrlsConfig } from '../oauth'
77
import { ILinkOAuthConfig } from './buttonTypes'
88

99
interface IOAuthButtonsProps {
@@ -31,6 +31,7 @@ interface IOAuthButtonsProps {
3131
* ```
3232
*/
3333
getOAuthUrls: FTGetOAuthUrls
34+
redirectUrlOverride: IGetOAuthUrlsConfig['redirectUrlOverride']
3435
/**
3536
* When the `action` is `link`, this config is required.
3637
*/
@@ -41,6 +42,7 @@ const OAuthButtons = ({
4142
action,
4243
layoutClasses = 'flex gap-2 flex-wrap justify-center',
4344
getOAuthUrls,
45+
redirectUrlOverride,
4446
linkOAuthConfig,
4547
}: IOAuthButtonsProps) => {
4648
if (!linkOAuthConfig && action === 'link') {
@@ -49,7 +51,7 @@ const OAuthButtons = ({
4951
)
5052
}
5153

52-
const oAuthUrls = getOAuthUrls({ method: action })
54+
const oAuthUrls = getOAuthUrls({ method: action, redirectUrlOverride })
5355
return (
5456
<ul className={layoutClasses}>
5557
{(() => {

web/src/oauth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ export interface IConnectedAccountRecord {
99
createdAt: Date
1010
}
1111

12-
interface IGetOAuthUrlsConfig {
12+
export interface IGetOAuthUrlsConfig {
1313
/**
1414
* By default, the redirect URL will be to whatever page the user is on when
1515
* they click the button. If you want to override this, you can pass in a
1616
* `redirectUrlOverride`.
17+
* Default is `window.location.origin + window.location.pathname`.
1718
*/
1819
redirectUrlOverride?: string
1920
/**

0 commit comments

Comments
 (0)