diff options
| author | LLLL Colonq <llll@colonq> | 2024-11-18 05:51:04 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2024-11-18 05:51:04 -0500 |
| commit | 229bbf710df29809b7fe0068c45d2c47a1908598 (patch) | |
| tree | cb0b756a5e4fec5dc7dbf3e1fb86742ded5794ab /src/Main.purs | |
| parent | ee790dfbe80ef1b8f7540334308025fc618bb659 (diff) | |
Fix logout
Diffstat (limited to 'src/Main.purs')
| -rw-r--r-- | src/Main.purs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/Main.purs b/src/Main.purs index bd9288e..e286a24 100644 --- a/src/Main.purs +++ b/src/Main.purs @@ -3,7 +3,7 @@ module Main where import Prelude import Audio as Audio -import Auth (AuthInfo, authHeader, getToken, startTwitchAuth, getSessionCookie, clearSessionCookie) +import Auth (AuthInfo, authHeader, getToken, startTwitchAuth, clearSessionCookie) import Config as Config import Data.String as String import Data.Array (head) @@ -232,8 +232,16 @@ mainMenu = launchAff_ do mainAuth :: Effect Unit mainAuth = launchAff_ do liftEffect $ log "hello from auth" - getSessionCookie >>= case _ of - Nothing -> do + { status } <- fetch "https://secure.colonq.computer/api/status" {} + case status of + 200 -> do + container <- byId "lcolonq-auth-logout" + removeClass "lcolonq-invisible" container + logout <- byId "lcolonq-auth-logout-link" + listen logout "click" \_ev -> do + clearSessionCookie + UI.reload + _ -> do container <- byId "lcolonq-auth-login" removeClass "lcolonq-invisible" container form <- byId "lcolonq-auth-form" @@ -243,20 +251,13 @@ mainAuth = launchAff_ do passwordInp <- byId "lcolonq-auth-password" username <- getValue usernameInp password <- getValue passwordInp - { text: resp } <- fetch ("/api/firstfactor") + { text: resp } <- fetch "/api/firstfactor" { method: POST , headers: { "Content-Type": "application/json" } , body: UI.toJSON { username, password } } res <- resp liftEffect $ log res - Just _ -> do - container <- byId "lcolonq-auth-logout" - removeClass "lcolonq-invisible" container - logout <- byId "lcolonq-auth-logout-link" - listen logout "click" \_ev -> do - clearSessionCookie - UI.reload main :: Effect Unit main = case Config.mode of |
