Watch for empty cookie strings

This commit is contained in:
Brian Hackett 2025-02-21 09:37:36 -08:00
parent a489a8d749
commit 7326682c94
2 changed files with 7 additions and 3 deletions

View File

@ -336,7 +336,9 @@ export const ChatImpl = memo(
}
const loginKey = getNutLoginKey();
const anthropicApiKey = Cookies.get(anthropicApiKeyCookieName);
const apiKeyCookie = Cookies.get(anthropicApiKeyCookieName);
const anthropicApiKey = apiKeyCookie?.length ? apiKeyCookie : undefined;
if (!loginKey && !anthropicApiKey) {
const numFreeUses = +(Cookies.get(anthropicNumFreeUsesCookieName) || 0);

View File

@ -134,7 +134,8 @@ const nutLoginKeyCookieName = 'nutLoginKey';
const nutIsAdminCookieName = 'nutIsAdmin';
export function getNutLoginKey(): string | undefined {
return Cookies.get(nutLoginKeyCookieName);
const cookieValue = Cookies.get(nutLoginKeyCookieName);
return cookieValue?.length ? cookieValue : undefined;
}
export function getNutIsAdmin(): boolean {
@ -169,7 +170,8 @@ export function setNutIsAdmin(isAdmin: boolean) {
const nutProblemsUsernameCookieName = 'nutProblemsUsername';
export function getProblemsUsername(): string | undefined {
return Cookies.get(nutProblemsUsernameCookieName);
const cookieValue = Cookies.get(nutProblemsUsernameCookieName);
return cookieValue?.length ? cookieValue : undefined;
}
export function saveProblemsUsername(username: string) {