Skip to content

Commit

Permalink
Support x_authentication_flow_group in reactnative sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
IniZio authored and louischan-oursky committed Apr 22, 2024
1 parent ec99782 commit a44231b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
28 changes: 25 additions & 3 deletions example/reactnative/src/screens/MainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const HomeScreen: React.FC = () => {
const [loading, setLoading] = useState(false);
const [clientID, setClientID] = useState('');
const [endpoint, setEndpoint] = useState('');
const [authenticationFlowGroup, setAuthenticationflowGroup] = useState('');
const [page, setPage] = useState('');
const [explicitColorScheme, setExplicitColorScheme] =
useState<ColorScheme | null>(null);
Expand Down Expand Up @@ -400,6 +401,7 @@ const HomeScreen: React.FC = () => {
wechatRedirectURI,
colorScheme: colorScheme as ColorScheme,
page,
authenticationFlowGroup,
})
.then(({userInfo}) => {
setUserInfo(userInfo);
Expand All @@ -412,7 +414,14 @@ const HomeScreen: React.FC = () => {
setLoading(false);
updateBiometricState();
});
}, [page, updateBiometricState, showError, showUser, colorScheme]);
}, [
page,
authenticationFlowGroup,
updateBiometricState,
showError,
showUser,
colorScheme,
]);

const loginAnonymously = useCallback(() => {
setLoading(true);
Expand Down Expand Up @@ -464,6 +473,7 @@ const HomeScreen: React.FC = () => {
redirectURI,
colorScheme: colorScheme as ColorScheme,
wechatRedirectURI,
authenticationFlowGroup,
},
biometricOptions,
);
Expand All @@ -480,7 +490,7 @@ const HomeScreen: React.FC = () => {
.finally(() => {
setLoading(false);
});
}, [showError, showUser, colorScheme]);
}, [authenticationFlowGroup, showError, showUser, colorScheme]);

const reauthenticateWebOnly = useCallback(() => {
async function task() {
Expand All @@ -495,6 +505,7 @@ const HomeScreen: React.FC = () => {
redirectURI,
colorScheme: colorScheme as ColorScheme,
wechatRedirectURI,
authenticationFlowGroup,
});

setUserInfo(userInfo);
Expand All @@ -509,7 +520,7 @@ const HomeScreen: React.FC = () => {
.finally(() => {
setLoading(false);
});
}, [showError, showUser, colorScheme]);
}, [authenticationFlowGroup, showError, showUser, colorScheme]);

const enableBiometric = useCallback(() => {
setLoading(true);
Expand Down Expand Up @@ -636,6 +647,17 @@ const HomeScreen: React.FC = () => {
placeholder="Enter endpoint"
/>
</View>
<View style={styles.input}>
<Text style={styles.inputLabel}>Authentication Flow Group</Text>
<TextInput
style={styles.inputField}
value={authenticationFlowGroup}
onChangeText={setAuthenticationflowGroup}
autoCapitalize="none"
autoCorrect={false}
placeholder="Enter flow group"
/>
</View>
<View style={styles.input}>
<Text style={styles.inputLabel}>Page</Text>
<RadioGroup
Expand Down
9 changes: 9 additions & 0 deletions packages/authgear-react-native/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export interface AuthenticateOptions {
* then set oauthProviderAlias to "google".
*/
oauthProviderAlias?: string;
/**
* Authentication flow group
*/
authenticationFlowGroup?: string;
}

/**
Expand Down Expand Up @@ -145,6 +149,11 @@ export interface ReauthenticateOptions {
* OIDC max_age
*/
maxAge?: number;

/**
* Authentication flow group
*/
authenticationFlowGroup?: string;
}

/**
Expand Down

0 comments on commit a44231b

Please sign in to comment.