From 9d844766ecb8f14527bb48bb2eedf5016e5cd28a Mon Sep 17 00:00:00 2001 From: uh wot Date: Tue, 10 Sep 2024 03:22:31 +0200 Subject: [PATCH] fix spotify stored creds login errors not being handled lol --- src/streamers/spotify/main.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/streamers/spotify/main.ts b/src/streamers/spotify/main.ts index 49709be..d8cfa75 100644 --- a/src/streamers/spotify/main.ts +++ b/src/streamers/spotify/main.ts @@ -39,23 +39,20 @@ class Spotify implements StreamerWithLogin { } } as const - loggedIn = false + username?: string + storedCredential?: string constructor(options: SpotifyOptions) { this.client = new Librespot(options) const { username, storedCredential } = options - if (username && storedCredential) { - this.client.loginWithStoredCreds(username, storedCredential) - this.loggedIn = true - } + this.username = username + this.storedCredential = storedCredential } async login(username: string, password: string) { - if (!this.loggedIn) { - const result = await this.client.login(username, password) - this.loggedIn = true - return result - } + if (this.username && this.storedCredential) + return await this.client.loginWithStoredCreds(this.username, this.storedCredential) + else return await this.client.login(username, password) } getStoredCredentials() { return this.client.getStoredCredentials()