sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import type { AuthenticationOptions } from "./account-api";
|
||||
|
||||
/** A missing options response must never fall back to a legacy guest login. */
|
||||
export function shouldStartSso(
|
||||
options: AuthenticationOptions | null,
|
||||
explicitSso: boolean,
|
||||
registering: boolean,
|
||||
sessionExpired = false,
|
||||
): boolean {
|
||||
return Boolean(options?.sso_enabled && !registering && !sessionExpired &&
|
||||
(explicitSso || !options.password_login_enabled));
|
||||
}
|
||||
|
||||
/** External callers put login parameters before or after the hash route. */
|
||||
export function mergeLoginSearch(routeSearch: string, outerSearch: string): URLSearchParams {
|
||||
const params = new URLSearchParams(outerSearch);
|
||||
// A route parameter wins even when explicitly empty: do not revive an old
|
||||
// outer credential when the current route has replaced it.
|
||||
new URLSearchParams(routeSearch).forEach((value, key) => params.set(key, value));
|
||||
return params;
|
||||
}
|
||||
|
||||
export const LOGIN_CREDENTIAL_PARAMS = [
|
||||
"ticket", "userId", "yUserId", "token", "access_token", "password", "authToken", "routeKey",
|
||||
] as const;
|
||||
|
||||
/** Cached tickets belong only to the legacy, bare entry with login disabled. */
|
||||
export function shouldUseStoredTicket(
|
||||
options: AuthenticationOptions | null,
|
||||
explicitSso: boolean,
|
||||
): boolean {
|
||||
return Boolean(options?.sso_enabled && !options.password_login_enabled && !explicitSso);
|
||||
}
|
||||
|
||||
/** Keep the destination/presentation when switching forms; discard credentials. */
|
||||
export function accountPageSearch(search: string, routeKeyTarget?: string): string {
|
||||
const params = new URLSearchParams(search);
|
||||
if (routeKeyTarget) params.set("redirect", routeKeyTarget);
|
||||
for (const key of LOGIN_CREDENTIAL_PARAMS) params.delete(key);
|
||||
const result = params.toString();
|
||||
return result ? `?${result}` : "";
|
||||
}
|
||||
Reference in new issue
Block a user