refactor, security updates, cv extraction upgrades
This commit is contained in:
@@ -1,26 +1,9 @@
|
||||
import { decodeJwtPayload, getAuthToken } from "./auth";
|
||||
import { getAuthUserKey } from "./auth";
|
||||
|
||||
export type ThemeModePref = "system" | "light" | "dark";
|
||||
|
||||
export function getUserKeyFromToken(): string {
|
||||
const token = getAuthToken();
|
||||
if (!token) return "anon";
|
||||
|
||||
const payload = decodeJwtPayload(token) ?? {};
|
||||
|
||||
const candidates = [
|
||||
payload.sub,
|
||||
payload.nameid,
|
||||
payload["nameid"],
|
||||
payload["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"],
|
||||
payload["http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid"],
|
||||
];
|
||||
|
||||
for (const c of candidates) {
|
||||
if (typeof c === "string" && c.trim().length > 0) return c.trim();
|
||||
}
|
||||
|
||||
return "anon";
|
||||
return getAuthUserKey();
|
||||
}
|
||||
|
||||
function k(base: string) {
|
||||
|
||||
Reference in New Issue
Block a user