Update index.html
Browse files- index.html +8 -1
index.html
CHANGED
|
@@ -22,16 +22,23 @@
|
|
| 22 |
<p>After clicking "Signin with HF", you will be redirected to this space and the access token + user info will be displayed.</p>
|
| 23 |
</div>
|
| 24 |
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/sign-in-with-huggingface-xl-dark.svg" alt="Sign in with Hugging Face" style="cursor: pointer; display: none;" id="signin">
|
|
|
|
| 25 |
<pre>
|
| 26 |
|
| 27 |
</pre>
|
| 28 |
<script type="module">
|
| 29 |
import { oauthLoginUrl, oauthHandleRedirectIfPresent } from "@huggingface/hub";
|
| 30 |
|
| 31 |
-
const oauthResult = await oauthHandleRedirectIfPresent();
|
| 32 |
|
| 33 |
if (oauthResult) {
|
| 34 |
document.querySelector("pre").textContent = JSON.stringify(oauthResult, null, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
} else {
|
| 36 |
document.getElementById("signin").style.removeProperty("display");
|
| 37 |
document.getElementById("signin").onclick = async function() {
|
|
|
|
| 22 |
<p>After clicking "Signin with HF", you will be redirected to this space and the access token + user info will be displayed.</p>
|
| 23 |
</div>
|
| 24 |
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/sign-in-with-huggingface-xl-dark.svg" alt="Sign in with Hugging Face" style="cursor: pointer; display: none;" id="signin">
|
| 25 |
+
<button id="signout" style="display: none">Sign out</button>
|
| 26 |
<pre>
|
| 27 |
|
| 28 |
</pre>
|
| 29 |
<script type="module">
|
| 30 |
import { oauthLoginUrl, oauthHandleRedirectIfPresent } from "@huggingface/hub";
|
| 31 |
|
| 32 |
+
const oauthResult = localStorage.get("oauth") || await oauthHandleRedirectIfPresent();
|
| 33 |
|
| 34 |
if (oauthResult) {
|
| 35 |
document.querySelector("pre").textContent = JSON.stringify(oauthResult, null, 2);
|
| 36 |
+
localStorage.setItem("oauth", oauthResult);
|
| 37 |
+
document.getElementById("signout").style.removeProperty("display");
|
| 38 |
+
document.getElementById("signout").onClick = async function() {
|
| 39 |
+
localStorage.removeItem("oauth");
|
| 40 |
+
window.location.href = window.location.href.replace(/\?.*$/, '');
|
| 41 |
+
}
|
| 42 |
} else {
|
| 43 |
document.getElementById("signin").style.removeProperty("display");
|
| 44 |
document.getElementById("signin").onclick = async function() {
|