Ensure that the userID is saved after both login and signup events
This commit is contained in:
parent
8b600143c7
commit
b1b67913bd
1 changed files with 9 additions and 7 deletions
|
@ -22,10 +22,7 @@ class UserAuthenticator {
|
|||
"password": password,
|
||||
}).then((response) {
|
||||
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());
|
||||
return true;
|
||||
} else {
|
||||
|
@ -44,9 +41,7 @@ class UserAuthenticator {
|
|||
"password": password,
|
||||
}).then((response) {
|
||||
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());
|
||||
return true;
|
||||
} else {
|
||||
|
@ -61,4 +56,11 @@ class UserAuthenticator {
|
|||
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"]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue