better loading indicators for timetables, talk and files
This commit is contained in:
@@ -98,8 +98,15 @@ class AccountData {
|
||||
|
||||
bool isPopulated() => _username != null && _password != null;
|
||||
|
||||
String buildHttpAuthString() {
|
||||
/// Returns the value for an HTTP `Authorization` header using HTTP Basic.
|
||||
/// Prefer this over embedding credentials in URLs — error logs and crash
|
||||
/// reports often capture the URL but not headers.
|
||||
String getBasicAuthHeader() {
|
||||
if (!isPopulated()) throw Exception('AccountData (e.g. username or password) is not initialized!');
|
||||
return '$_username:$_password';
|
||||
return 'Basic ${base64Encode(utf8.encode('$_username:$_password'))}';
|
||||
}
|
||||
|
||||
/// Convenience wrapper around [getBasicAuthHeader] returning a single-entry
|
||||
/// header map ready to merge into HTTP request headers.
|
||||
Map<String, String> authHeaders() => {'Authorization': getBasicAuthHeader()};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user