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 f11890a97b
commit dd550922fd
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() { data() {
return { 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 { tokenRenewAt(): Date | null {
if (this.tokenExpiresAt === null || this.tokenExpiresAt.getTime() < this.now.getTime()) { if (this.tokenExpiresAt === null) {
// We don't know when it expires or it's expired, we can't renew // We don't know when it expires, we can't renew
return null return null
} }
@ -88,7 +88,7 @@ const app = createApp({
this.tokenUser = username this.tokenUser = username
window.localStorage.setItem('twitch-bot-token', JSON.stringify({ expiresAt, token, username })) window.localStorage.setItem('twitch-bot-token', JSON.stringify({ expiresAt, token, username }))
// Nuke the Twitch auth-response from the browser history // 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) fetch(`config-editor/user?user=${this.tokenUser}`, this.$root.fetchOpts)
.then((resp: Response) => this.$root.parseResponseFromJSON(resp)) .then((resp: Response) => this.$root.parseResponseFromJSON(resp))