Skip to content

Commit

Permalink
Support x_authentication_flow_group in capacitor 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 a44231b commit fe061fd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
23 changes: 20 additions & 3 deletions example/capacitor/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function AuthgearDemo() {
const [endpoint, setEndpoint] = useState(() => {
return readEndpoint();
});
const [authenticationFlowGroup, setAuthenticationFlowGroup] = useState("");
const [page, setPage] = useState("");
const [colorScheme, setColorScheme] = useState("");
const [useTransientTokenStorage, setUseTransientTokenStorage] =
Expand Down Expand Up @@ -252,6 +253,7 @@ function AuthgearDemo() {
colorScheme:
colorScheme === "" ? undefined : (colorScheme as ColorScheme),
page: page === "" ? undefined : page,
authenticationFlowGroup,
});
showUserInfo(result.userInfo);
}
Expand All @@ -261,7 +263,14 @@ function AuthgearDemo() {
setLoading(false);
await updateBiometricState();
}
}, [colorScheme, page, showError, showUserInfo, updateBiometricState]);
}, [
authenticationFlowGroup,
colorScheme,
page,
showError,
showUserInfo,
updateBiometricState,
]);

const enableBiometric = useCallback(async () => {
setLoading(true);
Expand Down Expand Up @@ -329,6 +338,7 @@ function AuthgearDemo() {

authgearWeb.startReauthentication({
redirectURI: REDIRECT_URI_WEB_REAUTH,
authenticationFlowGroup,
});
} else {
await authgearCapacitor.refreshIDToken();
Expand All @@ -350,7 +360,7 @@ function AuthgearDemo() {
} finally {
setLoading(false);
}
}, [showError, colorScheme, showAuthTime]);
}, [authenticationFlowGroup, showError, colorScheme, showAuthTime]);

const reauthenticate = useCallback(async () => {
setLoading(true);
Expand All @@ -365,6 +375,7 @@ function AuthgearDemo() {

authgearWeb.startReauthentication({
redirectURI: REDIRECT_URI_WEB_REAUTH,
authenticationFlowGroup,
});
} else {
await authgearCapacitor.refreshIDToken();
Expand All @@ -389,7 +400,7 @@ function AuthgearDemo() {
} finally {
setLoading(false);
}
}, [showError, colorScheme, showAuthTime]);
}, [authenticationFlowGroup, showError, colorScheme, showAuthTime]);

const openSettings = useCallback(async () => {
if (isPlatformWeb()) {
Expand Down Expand Up @@ -674,6 +685,12 @@ function AuthgearDemo() {
onIonInput={onChangeEndpoint}
value={endpoint}
/>
<IonInput
type="text"
label="Authentication Flow Group"
placeholder="Enter Authentication Flow Group"
onIonInput={(e) => setAuthenticationFlowGroup(e.detail.value!)}
/>
<IonSelect label="Page" value={page} onIonChange={onChangePage}>
<IonSelectOption value="">Unset</IonSelectOption>
<IonSelectOption value="login">Login</IonSelectOption>
Expand Down
9 changes: 9 additions & 0 deletions packages/authgear-capacitor/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export interface AuthenticateOptions {
* then set oauthProviderAlias to "google".
*/
oauthProviderAlias?: string;
/**
* Authentication flow group
*/
authenticationFlowGroup?: string;
}

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

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

/**
Expand Down

0 comments on commit fe061fd

Please sign in to comment.