[core] Fix: Properly handle channels without credentials

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-12-14 16:49:33 +01:00
parent eec4966b82
commit 3ac5284583
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -172,6 +172,13 @@ func (s Service) GetTwitchClientForChannel(channel string, cfg ClientConfig) (*t
return nil, errors.Wrap(err, "decrypting refresh token")
}
if perm.AccessToken == "" && perm.RefreshToken == "" {
// We have no tokens but an entry in the permission table: Means
// we still can't do stuff on behalf of that channel so we treat
// that as an unauthorized channel
return nil, ErrChannelNotAuthorized
}
scopes := strings.Split(perm.Scopes, " ")
tc := twitch.New(cfg.TwitchClient, cfg.TwitchClientSecret, perm.AccessToken, perm.RefreshToken)