Skip to content

Commit c06330f

Browse files
committed
add switchToOrganization
1 parent 30dafb9 commit c06330f

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ The `useAuth` hook returns user information and helper functions:
109109
- `signIn`: Redirects the user to the Hosted AuthKit sign-in page. Takes an optional `state` argument.
110110
- `signUp`: Redirects the user to the Hosted AuthKit sign-up page. Takes an optional `state` argument.
111111
- `signOut`: Ends the session.
112+
- `switchToOrganization`: Switches to the given organization. Redirects to the hosted login page if switch is unsuccessful.
112113
113114
The following claims may be populated if the user is part of an organization:
114115

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
"react": ">=17"
3838
},
3939
"dependencies": {
40-
"@workos-inc/authkit-js": "0.6.1"
40+
"@workos-inc/authkit-js": "0.7.0"
4141
}
4242
}

src/provider.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export function AuthKitProvider(props: AuthKitProviderProps) {
6868
signIn: client.signIn.bind(client),
6969
signUp: client.signUp.bind(client),
7070
signOut: client.signOut.bind(client),
71+
switchToOrganization: client.switchToOrganization.bind(client),
7172
});
7273
setState((prev) => ({ ...prev, isLoading: false, user }));
7374
});
@@ -109,5 +110,6 @@ const NOOP_CLIENT: Client = {
109110
signUp: async () => {},
110111
getUser: () => null,
111112
getAccessToken: () => Promise.reject(new LoginRequiredError()),
113+
switchToOrganization: () => Promise.resolve(),
112114
signOut: () => {},
113115
};

src/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import { createClient } from "@workos-inc/authkit-js";
22

33
export type Client = Pick<
44
Awaited<ReturnType<typeof createClient>>,
5-
"signIn" | "signUp" | "getUser" | "getAccessToken" | "signOut"
5+
| "signIn"
6+
| "signUp"
7+
| "getUser"
8+
| "getAccessToken"
9+
| "signOut"
10+
| "switchToOrganization"
611
>;
712

813
export type CreateClientOptions = NonNullable<

0 commit comments

Comments
 (0)