mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-22 11:30:59 +00:00
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:
parent
8d6751c88d
commit
3d01c9b363
1 changed files with 25 additions and 10 deletions
|
@ -132,16 +132,31 @@ impl Settings {
|
||||||
let cache = Cache::new(credentials_cache, None, files_cache, max_size)?;
|
let cache = Cache::new(credentials_cache, None, files_cache, max_size)?;
|
||||||
|
|
||||||
if let Some(cached_cred) = cache.credentials() {
|
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 {
|
||||||
if let Ok((session, _credentials)) = Session::connect(
|
gst::debug!(
|
||||||
SessionConfig::default(),
|
cat,
|
||||||
cached_cred,
|
obj: &src,
|
||||||
Some(cache.clone()),
|
"ignore cached credentials for user {} which mismatch user {}",
|
||||||
true,
|
cached_cred.username,
|
||||||
)
|
self.username
|
||||||
.await
|
);
|
||||||
{
|
} else {
|
||||||
return Ok(session);
|
gst::debug!(
|
||||||
|
cat,
|
||||||
|
obj: &src,
|
||||||
|
"reuse cached credentials for user {}",
|
||||||
|
cached_cred.username
|
||||||
|
);
|
||||||
|
if let Ok((session, _credentials)) = Session::connect(
|
||||||
|
SessionConfig::default(),
|
||||||
|
cached_cred,
|
||||||
|
Some(cache.clone()),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
return Ok(session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue