From 3186afe96defbd040a0d640bdab1455e7f170e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?c=C4=83t=C4=83lin?= Date: Thu, 19 Dec 2024 18:50:05 +0100 Subject: [PATCH] fix: fix logout flow which wasn't being triggered, remove useless html code --- charts/huesoporro/Chart.yaml | 2 +- charts/huesoporro/values.yaml | 2 +- pyproject.toml | 2 +- src/huesoporro/api/routes/api.py | 2 +- src/huesoporro/static/js/utils.js | 33 ------------- src/huesoporro/templates/index.html | 12 ++--- src/huesoporro/templates/login.html | 62 +------------------------ src/huesoporro/templates/logout.html | 13 ++++++ src/huesoporro/templates/sentences.html | 15 +++--- src/huesoporro/templates/tts.html | 7 +-- uv.lock | 2 +- 11 files changed, 34 insertions(+), 118 deletions(-) create mode 100644 src/huesoporro/templates/logout.html diff --git a/charts/huesoporro/Chart.yaml b/charts/huesoporro/Chart.yaml index 22ca75f..3d392ad 100644 --- a/charts/huesoporro/Chart.yaml +++ b/charts/huesoporro/Chart.yaml @@ -21,4 +21,4 @@ version: 0.2.4 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.2.4" +appVersion: "0.2.5" diff --git a/charts/huesoporro/values.yaml b/charts/huesoporro/values.yaml index 48b749a..ea27e5a 100644 --- a/charts/huesoporro/values.yaml +++ b/charts/huesoporro/values.yaml @@ -11,7 +11,7 @@ image: # This sets the pull policy for images. pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. - tag: "0.2.4" + tag: "0.2.5" # This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ imagePullSecrets: [] diff --git a/pyproject.toml b/pyproject.toml index 5b913bf..1da3c58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "huesoporro" -version = "0.2.4" +version = "0.2.5" description = "Misc Twitch bots" readme = "README.md" authors = [ diff --git a/src/huesoporro/api/routes/api.py b/src/huesoporro/api/routes/api.py index d427cde..9412598 100644 --- a/src/huesoporro/api/routes/api.py +++ b/src/huesoporro/api/routes/api.py @@ -19,7 +19,7 @@ class ManageBotDTO(BaseModel): "/tts", media_type=MediaType.HTML, ) -async def get_tts_overlay() -> Template: +async def get_tts_overlay(user: User) -> Template: return Template(template_name="tts.html") diff --git a/src/huesoporro/static/js/utils.js b/src/huesoporro/static/js/utils.js index e014ab2..9bb1116 100644 --- a/src/huesoporro/static/js/utils.js +++ b/src/huesoporro/static/js/utils.js @@ -7,36 +7,3 @@ function getWebsocketProtocol() { return "wss://"; } } - -function addLogoutEvent() { - const logoutButton = document.getElementById("logoutButton"); - logoutButton.addEventListener("click", () => { - document.cookie = "twitchLoginData=; expires=Thu, 01 Jan 1970 00:00:00 UTC"; - window.location.href = "/"; - }); - -} - -function setCookie(name, value, days) { - const date = new Date(); - date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); - const expires = `expires=${date.toUTCString()}`; - document.cookie = `${name}=${value};${expires};path=/;SameSite=Strict`; -} - -function getCookie(name) { - const cookieName = `${name}=`; - const decodedCookie = decodeURIComponent(document.cookie); - const cookieArray = decodedCookie.split(';'); - - for (let i = 0; i < cookieArray.length; i++) { - let cookie = cookieArray[i]; - while (cookie.charAt(0) === ' ') { - cookie = cookie.substring(1); - } - if (cookie.indexOf(cookieName) === 0) { - return cookie.substring(cookieName.length, cookie.length); - } - } - return null; -} diff --git a/src/huesoporro/templates/index.html b/src/huesoporro/templates/index.html index bdf08ee..b17419f 100644 --- a/src/huesoporro/templates/index.html +++ b/src/huesoporro/templates/index.html @@ -5,12 +5,10 @@
@@ -178,7 +176,7 @@ }) const data = await response.json() console.log(data); - if (response.ok){ + if (response.ok) { alert("Settings saved successfully") } } @@ -186,8 +184,6 @@ const chatbotManager = new ChatbotManager(); chatbotManager.setEvents(); - - addLogoutEvent() }); diff --git a/src/huesoporro/templates/login.html b/src/huesoporro/templates/login.html index 00e0a38..3a3181a 100644 --- a/src/huesoporro/templates/login.html +++ b/src/huesoporro/templates/login.html @@ -6,7 +6,8 @@
- Login + Login with Twitch @@ -14,66 +15,7 @@
diff --git a/src/huesoporro/templates/logout.html b/src/huesoporro/templates/logout.html new file mode 100644 index 0000000..61f189c --- /dev/null +++ b/src/huesoporro/templates/logout.html @@ -0,0 +1,13 @@ + + diff --git a/src/huesoporro/templates/sentences.html b/src/huesoporro/templates/sentences.html index 7a0b611..e390f79 100644 --- a/src/huesoporro/templates/sentences.html +++ b/src/huesoporro/templates/sentences.html @@ -1,17 +1,14 @@ - {% include 'header.html' %}

Huesoporro🦴🍃

@@ -20,14 +17,18 @@ - + {% for sentence in sentences %} - + {% endfor %}
SentenceSentence Action
{{ sentence.sentence }} + +
diff --git a/src/huesoporro/templates/tts.html b/src/huesoporro/templates/tts.html index a0f3266..5a7843e 100644 --- a/src/huesoporro/templates/tts.html +++ b/src/huesoporro/templates/tts.html @@ -8,10 +8,7 @@
  • TTS
  • Le Funny
  • - - + {% include 'logout.html' %}

    Huesoporro🦴🍃

    @@ -186,7 +183,7 @@ // generate /tts/permalink?access_token= // the access token is available in the twitchLoginData cookie - const cookie = JSON.parse(getCookie("twitchLoginData")) + const cookie = JSON.parse(getCookie("huesoporroAuth")) const permalinkUrl = `${window.location.origin}/tts/permalink?access_token=${cookie.access_token}`; navigator.clipboard.writeText(permalinkUrl); alert('OBS link copied to clipboard ' + permalinkUrl); diff --git a/uv.lock b/uv.lock index c6caf63..d861103 100644 --- a/uv.lock +++ b/uv.lock @@ -460,7 +460,7 @@ wheels = [ [[package]] name = "huesoporro" -version = "0.2.4" +version = "0.2.5" source = { virtual = "." } dependencies = [ { name = "aiosqlite" },