feat: add oidc

This commit is contained in:
David Nguyen
2025-02-14 16:01:16 +11:00
parent 113ab293bb
commit 31de86e425
10 changed files with 443 additions and 254 deletions

View File

@ -118,7 +118,10 @@ export class AuthClient {
public google = {
signIn: async ({ redirectPath }: { redirectPath?: string } = {}) => {
const response = await this.client['google'].authorize.$post({ json: { redirectPath } });
const response = await this.client['oauth'].authorize.google.$post({
json: { redirectPath },
});
await this.handleError(response);
const data = await response.json();
@ -129,6 +132,20 @@ export class AuthClient {
}
},
};
public oidc = {
signIn: async ({ redirectPath }: { redirectPath?: string } = {}) => {
const response = await this.client['oauth'].authorize.oidc.$post({ json: { redirectPath } });
await this.handleError(response);
const data = await response.json();
// Redirect to external OIDC provider URL.
if (data.redirectUrl) {
window.location.href = data.redirectUrl;
}
},
};
}
export const authClient = new AuthClient({