Improve login/logout flow

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2024-06-20 17:53:42 +02:00
parent afb4bf91a2
commit 4d1a4cc936
Signed by: luzifer
SSH Key Fingerprint: SHA256:/xtE5lCgiRDQr8SLxHMS92ZBlACmATUmF1crK16Ks4E
2 changed files with 4 additions and 4 deletions

View File

@ -79,7 +79,7 @@ export default defineComponent({
data() {
return {
socketConnected: false,
socketConnected: true, // Directly after load it should always be connected
}
},

View File

@ -31,8 +31,8 @@ const app = createApp({
},
tokenRenewAt(): Date | null {
if (this.tokenExpiresAt === null || this.tokenExpiresAt.getTime() < this.now.getTime()) {
// We don't know when it expires or it's expired, we can't renew
if (this.tokenExpiresAt === null) {
// We don't know when it expires, we can't renew
return null
}
@ -88,7 +88,7 @@ const app = createApp({
this.tokenUser = username
window.localStorage.setItem('twitch-bot-token', JSON.stringify({ expiresAt, token, username }))
// Nuke the Twitch auth-response from the browser history
window.history.replaceState(null, '', window.location.href.split('#')[0])
this.$router.replace({ name: 'dashboard' })
fetch(`config-editor/user?user=${this.tokenUser}`, this.$root.fetchOpts)
.then((resp: Response) => this.$root.parseResponseFromJSON(resp))