spotify: check cached creds username before use

If a username was specified, only use cached credentials that match
that username.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1204>
This commit is contained in:
Nick Steel 2023-04-23 22:16:40 +01:00 committed by Sebastian Dröge
parent fc5ff9503d
commit adfceaea77

View file

@ -474,11 +474,14 @@ impl SpotifyAudioSrc {
let cache = Cache::new(credentials_cache, None, files_cache, max_size)?;
let credentials = match cache.credentials() {
Some(cached_cred) => {
Some(cached_cred)
if settings.username.is_empty()
|| settings.username == cached_cred.username =>
{
gst::debug!(CAT, imp: self, "reuse credentials from cache",);
cached_cred
}
None => {
_ => {
gst::debug!(CAT, imp: self, "credentials not in cache",);
if settings.username.is_empty() {