41 lines
768 B
TypeScript
41 lines
768 B
TypeScript
import { APIClient } from "./ApiClient";
|
|
|
|
export class AuthApi {
|
|
/**
|
|
* Start OpenID login
|
|
*/
|
|
static async StartOpenIDLogin(): Promise<{ url: string }> {
|
|
return (
|
|
await APIClient.exec({
|
|
uri: "/auth/start_oidc",
|
|
method: "GET",
|
|
})
|
|
).data;
|
|
}
|
|
|
|
/**
|
|
* Finish OpenID login
|
|
*/
|
|
static async FinishOpenIDLogin(code: string, state: string): Promise<void> {
|
|
await APIClient.exec({
|
|
uri: "/auth/finish_oidc",
|
|
method: "POST",
|
|
jsonData: { code: code, state: state },
|
|
});
|
|
|
|
window.location.href = "/";
|
|
}
|
|
|
|
/**
|
|
* Sign out
|
|
*/
|
|
static async SignOut(): Promise<void> {
|
|
await APIClient.exec({
|
|
uri: "/auth/sign_out",
|
|
method: "GET",
|
|
});
|
|
|
|
window.location.href = "/";
|
|
}
|
|
}
|