Spaces:
Sleeping
Sleeping
Julian Bilcke
commited on
Commit
·
9009efd
1
Parent(s):
daa3cb1
let's hack Hugging Face
Browse files
src/app/state/userCurrentUser.ts
CHANGED
|
@@ -100,6 +100,20 @@ export function useCurrentUser({
|
|
| 100 |
|
| 101 |
// can be called many times, but won't do the API call if not necessary
|
| 102 |
const main = async (isLoginRequired: boolean) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
console.log("useCurrentUser()")
|
| 105 |
const searchParams = new URLSearchParams(window.location.search);
|
|
@@ -191,6 +205,7 @@ export function useCurrentUser({
|
|
| 191 |
console.log("hack:", hack)
|
| 192 |
localStorage.setItem("aitube.at:login", hack)
|
| 193 |
|
|
|
|
| 194 |
window.location.href = oauthUrl
|
| 195 |
}
|
| 196 |
|
|
|
|
| 100 |
|
| 101 |
// can be called many times, but won't do the API call if not necessary
|
| 102 |
const main = async (isLoginRequired: boolean) => {
|
| 103 |
+
try {
|
| 104 |
+
// let's pirate hugging face! 🤗
|
| 105 |
+
// @admins chill, it's not what you think, but more like a Next/React hack
|
| 106 |
+
const hack = localStorage.getItem("aitube.at:login") || "{}"
|
| 107 |
+
if (hack) {
|
| 108 |
+
const hacked = JSON.parse(hack)
|
| 109 |
+
localStorage.setItem("huggingface.co:oauth:nonce", hacked.nonce)
|
| 110 |
+
localStorage.setItem("huggingface.co:oauth:code_verifier", hacked.codeVerifier)
|
| 111 |
+
localStorage.removeItem("aitube.at:login")
|
| 112 |
+
console.log("successfully hacked Hugging Face and removed traces of our deed 🤗")
|
| 113 |
+
}
|
| 114 |
+
} catch (err) {
|
| 115 |
+
console.log("failed to hack Hugging Face! :sadface:")
|
| 116 |
+
}
|
| 117 |
|
| 118 |
console.log("useCurrentUser()")
|
| 119 |
const searchParams = new URLSearchParams(window.location.search);
|
|
|
|
| 205 |
console.log("hack:", hack)
|
| 206 |
localStorage.setItem("aitube.at:login", hack)
|
| 207 |
|
| 208 |
+
// should we open this in a new tab?
|
| 209 |
window.location.href = oauthUrl
|
| 210 |
}
|
| 211 |
|