changing sign in out icon depending on the account state

This commit is contained in:
Miodec 2022-08-24 14:56:07 +02:00
parent ee1eb8c8aa
commit dd0d1d8e95
2 changed files with 17 additions and 4 deletions

View file

@ -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(
`<i class="fas fa-fw fa-sign-out-alt"></i>`
);
await loadUser(user);
} else {
$("#top .signInOut .icon").html(`<i class="fas fa-fw fa-sign-in-alt"></i>`);
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) => {

View file

@ -143,9 +143,14 @@
<i class="fas fa-fw fa-bell"></i>
</div>
</a> -->
<a class="textButton signOut" tabindex="2" onclick="this.blur();" data-link>
<a
class="textButton signInOut"
tabindex="2"
onclick="this.blur();"
data-link
>
<div class="icon">
<i class="fas fa-fw fa-sign-out-alt"></i>
<i class="fas fa-fw fa-sign-in-alt"></i>
</div>
</a>
</div>