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/1192>
This commit is contained in:
Nick Steel 2023-04-23 22:16:40 +01:00 committed by kingosticks
parent 8d6751c88d
commit 3d01c9b363

View file

@ -132,7 +132,21 @@ impl Settings {
let cache = Cache::new(credentials_cache, None, files_cache, max_size)?;
if let Some(cached_cred) = cache.credentials() {
gst::debug!(cat, obj: &src, "reuse credentials from cache",);
if !self.username.is_empty() && self.username != cached_cred.username {
gst::debug!(
cat,
obj: &src,
"ignore cached credentials for user {} which mismatch user {}",
cached_cred.username,
self.username
);
} else {
gst::debug!(
cat,
obj: &src,
"reuse cached credentials for user {}",
cached_cred.username
);
if let Ok((session, _credentials)) = Session::connect(
SessionConfig::default(),
cached_cred,
@ -144,6 +158,7 @@ impl Settings {
return Ok(session);
}
}
}
gst::debug!(
cat,