import { AuthApi } from "../api/AuthApi";
import { AsyncWidget } from "../widgets/AsyncWidget";
export function AuthRouteWidget(): React.ReactElement {
const params = new URL(document.location.toString()).searchParams;
const code = params.get("code");
const state = params.get("state");
// Initiate OpenID login
if (!code || !state) return ;
// Finish OpenID login
return ;
}
function InitOpenIDAuth() {
const load = async () => {
const res = await AuthApi.StartOpenIDLogin();
window.location.href = res.url;
};
return (
<>ready for auth>}
/>
);
}
function FinishOpenIDAuth(p: { code: string; state: string }) {
const load = async () => {
await AuthApi.FinishOpenIDLogin(p.code, p.state);
};
return (
<>Auth successfully finished. App should restart now.>}
/>
);
}