mirror of
https://github.com/tinyauthapp/tinyauth.git
synced 2026-08-28 00:13:35 +08:00
22 lines
552 B
TypeScript
22 lines
552 B
TypeScript
type UseLoginForProps = {
|
|
login_for?: "oidc" | "app";
|
|
params: URLSearchParams;
|
|
};
|
|
|
|
export const useLoginFor = (props: UseLoginForProps): string => {
|
|
const { login_for, params } = props;
|
|
const compiledParams = params.toString() ? "?" + params.toString() : "";
|
|
|
|
switch (login_for) {
|
|
case "oidc":
|
|
return "/oidc/authorize" + compiledParams;
|
|
case "app":
|
|
return "/continue" + compiledParams;
|
|
default:
|
|
if (params.get("redirect_uri")) {
|
|
return "/continue" + compiledParams
|
|
}
|
|
return "/logout";
|
|
}
|
|
};
|