jbilcke-hf HF staff commited on
Commit
3f55819
1 Parent(s): 6365220
Files changed (1) hide show
  1. src/app/state/useCurrentUser.ts +8 -1
src/app/state/useCurrentUser.ts CHANGED
@@ -56,8 +56,15 @@ export function useCurrentUser({
56
  const checkSession = async (isLoginRequired: boolean = false): Promise<UserInfo | undefined> => {
57
 
58
  console.log("useCurrentUser.checkSession()")
59
- const huggingfaceTemporaryApiKey = localStorage.getItem(localStorageKeys.huggingfaceTemporaryApiKey) || ""
 
60
  console.log("huggingfaceTemporaryApiKey:", huggingfaceTemporaryApiKey)
 
 
 
 
 
 
61
  // new way: try to use the safer temporary key whenever possible
62
  if (huggingfaceTemporaryApiKey) {
63
  try {
 
56
  const checkSession = async (isLoginRequired: boolean = false): Promise<UserInfo | undefined> => {
57
 
58
  console.log("useCurrentUser.checkSession()")
59
+ let huggingfaceTemporaryApiKey = localStorage.getItem(localStorageKeys.huggingfaceTemporaryApiKey) || ""
60
+
61
  console.log("huggingfaceTemporaryApiKey:", huggingfaceTemporaryApiKey)
62
+ if (huggingfaceApiKey.startsWith('"')) {
63
+ console.log("the key has been corrupted..")
64
+ localStorage.setItem(localStorageKeys.huggingfaceTemporaryApiKey, JSON.parse(huggingfaceApiKey))
65
+ huggingfaceTemporaryApiKey = localStorage.getItem(localStorageKeys.huggingfaceTemporaryApiKey) || ""
66
+ console.log(`the recovered key is: ${huggingfaceTemporaryApiKey}`)
67
+ }
68
  // new way: try to use the safer temporary key whenever possible
69
  if (huggingfaceTemporaryApiKey) {
70
  try {