sync update from LAN repo (source master @ ca48c4ec)
This commit is contained in:
1 parent
8bc8b0e082
commit
ea9dcff9c0
873 files changed
+107866
-14011
No files matched your search
@@ -11,6 +11,13 @@ export function shouldStartSso(
|
||||
(explicitSso || !options.password_login_enabled));
|
||||
}
|
||||
|
||||
/** Claim the one automatic SSO login started by a mounted LoginPage. */
|
||||
export function claimSsoLoginStart(started: { current: boolean }): boolean {
|
||||
if (started.current) return false;
|
||||
started.current = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** External callers put login parameters before or after the hash route. */
|
||||
export function mergeLoginSearch(routeSearch: string, outerSearch: string): URLSearchParams {
|
||||
const params = new URLSearchParams(outerSearch);
|
||||
@@ -20,6 +27,31 @@ export function mergeLoginSearch(routeSearch: string, outerSearch: string): URLS
|
||||
return params;
|
||||
}
|
||||
|
||||
const OUTER_IDENTITY_PARAMS = ["authToken", "yUserId", "ticket", "token", "access_token", "userId"] as const;
|
||||
|
||||
/**
|
||||
* `/login/:username?password=` names the account. Identity params left in front
|
||||
* of the hash by an earlier external-token entry must not sign that user back
|
||||
* in. The same keys written inside the hash route are still honored.
|
||||
*/
|
||||
export function loginParamsForEntry(
|
||||
routeSearch: string,
|
||||
outerSearch: string,
|
||||
routeUsername?: string | null,
|
||||
): URLSearchParams {
|
||||
const params = mergeLoginSearch(routeSearch, outerSearch);
|
||||
const route = new URLSearchParams(routeSearch);
|
||||
const username = routeUsername?.trim() ?? "";
|
||||
const password = route.has("password")
|
||||
? (route.get("password") ?? "")
|
||||
: (new URLSearchParams(outerSearch).get("password") ?? "");
|
||||
if (!username || !password) return params;
|
||||
for (const key of OUTER_IDENTITY_PARAMS) {
|
||||
if (!route.has(key)) params.delete(key);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
export const LOGIN_CREDENTIAL_PARAMS = [
|
||||
"ticket", "userId", "yUserId", "token", "access_token", "password", "authToken", "routeKey",
|
||||
] as const;
|
||||
@@ -28,8 +60,9 @@ export const LOGIN_CREDENTIAL_PARAMS = [
|
||||
export function shouldUseStoredTicket(
|
||||
options: AuthenticationOptions | null,
|
||||
explicitSso: boolean,
|
||||
hasCurrentSession = false,
|
||||
): boolean {
|
||||
return Boolean(options?.sso_enabled && !options.password_login_enabled && !explicitSso);
|
||||
return Boolean(options?.sso_enabled && !options.password_login_enabled && !explicitSso && !hasCurrentSession);
|
||||
}
|
||||
|
||||
/** Keep the destination/presentation when switching forms; discard credentials. */
|
||||
|
||||
Reference in new issue
Block a user