Send user agent header with app version when logging in and registering

This commit is contained in:
Roland Geider
2021-11-08 09:57:18 +01:00
parent 1e9c44e56b
commit fbff8f5425

View File

@@ -110,7 +110,8 @@ class AuthProvider with ChangeNotifier {
makeUri(serverUrl, REGISTRATION_URL),
headers: {
HttpHeaders.contentTypeHeader: 'application/json; charset=UTF-8',
HttpHeaders.authorizationHeader: 'Token ${metadata![MANIFEST_KEY_API]}'
HttpHeaders.authorizationHeader: 'Token ${metadata![MANIFEST_KEY_API]}',
HttpHeaders.userAgentHeader: getAppNameHeader(),
},
body: json.encode(data),
);
@@ -135,6 +136,7 @@ class AuthProvider with ChangeNotifier {
makeUri(serverUrl, LOGIN_URL),
headers: <String, String>{
HttpHeaders.contentTypeHeader: 'application/json; charset=UTF-8',
HttpHeaders.userAgentHeader: getAppNameHeader(),
},
body: json.encode({'username': username, 'password': password}),
);
@@ -219,10 +221,10 @@ class AuthProvider with ChangeNotifier {
String getAppNameHeader() {
String out = '';
if (applicationVersion != null) {
out = '${applicationVersion!.version} '
out = '/${applicationVersion!.version} '
'(${applicationVersion!.packageName}; '
'build: ${applicationVersion!.buildNumber})';
}
return 'wger App/$out';
return 'wger App$out';
}
}