From dd0d1d8e95fa7e88ed21b790b7c26e7cc0eeef69 Mon Sep 17 00:00:00 2001 From: Miodec Date: Wed, 24 Aug 2022 14:56:07 +0200 Subject: [PATCH] changing sign in out icon depending on the account state --- frontend/src/ts/controllers/account-controller.ts | 12 ++++++++++-- frontend/static/html/top.html | 9 +++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index ffeb71f36..884e44949 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -274,8 +274,12 @@ const authListener = Auth.onAuthStateChanged(async function (user) { const hash = window.location.hash; console.log(`auth state changed, user ${user ? true : false}`); if (user) { + $("#top .signInOut .icon").html( + `` + ); await loadUser(user); } else { + $("#top .signInOut .icon").html(``); if (window.location.pathname == "/account") { window.history.replaceState("", "", "/login"); } @@ -643,8 +647,12 @@ $(".pageLogin .login .button.signInWithGoogle").on("click", () => { // signInWithGitHub(); // }); -$("#top .signOut").on("click", () => { - signOut(); +$("#top .signInOut").on("click", () => { + if (Auth.currentUser) { + signOut(); + } else { + navigate("/login"); + } }); $(".pageLogin .register input").keyup((e) => { diff --git a/frontend/static/html/top.html b/frontend/static/html/top.html index f71618e42..ab8d3e5ea 100644 --- a/frontend/static/html/top.html +++ b/frontend/static/html/top.html @@ -143,9 +143,14 @@ --> - +
- +