Merge commit '394fd672'
This commit is contained in:
@@ -85,6 +85,28 @@ class ServerSession {
|
||||
return headers;
|
||||
}
|
||||
|
||||
/// Read one profile without changing the selected socket or credentials.
|
||||
static Future<Map<String, String> Function(Uri)> credentialReader({
|
||||
required String id,
|
||||
required Iterable<Uri> endpoints,
|
||||
}) async {
|
||||
final origins = endpoints.map(loginUriFor).whereType<Uri>().toSet();
|
||||
final key = _scopeKey(id);
|
||||
final version = _versions[key];
|
||||
final value = id == _serverId
|
||||
? cookie
|
||||
: (await SharedPreferences.getInstance()).getString(key);
|
||||
return (Uri uri) {
|
||||
if (_versions[key] != version ||
|
||||
!origins.contains(loginUriFor(uri)) ||
|
||||
value == null ||
|
||||
value.isEmpty) {
|
||||
return const <String, String>{};
|
||||
}
|
||||
return <String, String>{'Cookie': value};
|
||||
};
|
||||
}
|
||||
|
||||
static Future<void> load() async {
|
||||
final generation = ++_generation;
|
||||
_serverId = null;
|
||||
|
||||
Reference in New Issue
Block a user