From d5ffc77a120b304d98dbd31b3272bcd312334385 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 26 Nov 2024 04:13:31 -0500 Subject: Redirect URL on login page --- src/Main.purs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/Main.purs') diff --git a/src/Main.purs b/src/Main.purs index 983a805..c4b4fa5 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, clearSessionCookie, getRedirect) +import Auth (AuthInfo, authHeader, getToken, startTwitchAuth, clearSessionCookie, getQueryRedirect, getResponseRedirect) import Config as Config import Data.String as String import Data.Array (head) @@ -248,13 +248,20 @@ mainAuth = launchAff_ do passwordInp <- byId "lcolonq-auth-password" username <- getValue usernameInp password <- getValue passwordInp + rd <- getQueryRedirect { json: resp } <- fetch "/api/firstfactor" { method: POST , headers: { "Content-Type": "application/json" } - , body: UI.toJSON { username, password } + , body: UI.toJSON + { username + , password + , targetURL: case rd of + Just r -> r + Nothing -> "https://secure.colonq.computer" + } } res <- resp - getRedirect res >>= case _ of + getResponseRedirect res >>= case _ of Nothing -> do err <- byId "lcolonq-auth-error" removeClass "lcolonq-invisible" err -- cgit v1.2.3