|
@@ -22,10 +22,7 @@ class UserAuthenticator {
|
|
"password": password,
|
|
"password": password,
|
|
}).then((response) {
|
|
}).then((response) {
|
|
if (response.statusCode == 200 && response.data != null) {
|
|
if (response.statusCode == 200 && response.data != null) {
|
|
- Configuration.instance.setUsername(username);
|
|
|
|
- Configuration.instance.setPassword(password);
|
|
|
|
- Configuration.instance.setUserID(response.data["id"]);
|
|
|
|
- Configuration.instance.setToken(response.data["token"]);
|
|
|
|
|
|
+ _saveConfiguration(username, password, response);
|
|
Bus.instance.fire(UserAuthenticatedEvent());
|
|
Bus.instance.fire(UserAuthenticatedEvent());
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|
|
@@ -44,9 +41,7 @@ class UserAuthenticator {
|
|
"password": password,
|
|
"password": password,
|
|
}).then((response) {
|
|
}).then((response) {
|
|
if (response.statusCode == 200 && response.data != null) {
|
|
if (response.statusCode == 200 && response.data != null) {
|
|
- Configuration.instance.setUsername(username);
|
|
|
|
- Configuration.instance.setPassword(password);
|
|
|
|
- Configuration.instance.setToken(response.data["token"]);
|
|
|
|
|
|
+ _saveConfiguration(username, password, response);
|
|
Bus.instance.fire(UserAuthenticatedEvent());
|
|
Bus.instance.fire(UserAuthenticatedEvent());
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|
|
@@ -61,4 +56,11 @@ class UserAuthenticator {
|
|
throw e;
|
|
throw e;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ void _saveConfiguration(String username, String password, Response response) {
|
|
|
|
+ Configuration.instance.setUsername(username);
|
|
|
|
+ Configuration.instance.setPassword(password);
|
|
|
|
+ Configuration.instance.setUserID(response.data["id"]);
|
|
|
|
+ Configuration.instance.setToken(response.data["token"]);
|
|
|
|
+ }
|
|
}
|
|
}
|