mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-02-04 09:43:19 +00:00
Refactor token handling in InvenTreeAPI: reset token on request failure and save on success
This commit is contained in:
parent
3b05b6fe54
commit
2f95ac3209
1 changed files with 7 additions and 2 deletions
|
|
@ -546,8 +546,6 @@ class InvenTreeAPI {
|
||||||
userProfile.token = token;
|
userProfile.token = token;
|
||||||
profile = userProfile;
|
profile = userProfile;
|
||||||
|
|
||||||
await UserProfileDBManager().updateProfile(userProfile);
|
|
||||||
|
|
||||||
final response = await get(_URL_ME);
|
final response = await get(_URL_ME);
|
||||||
|
|
||||||
if (!response.successful()) {
|
if (!response.successful()) {
|
||||||
|
|
@ -564,6 +562,13 @@ class InvenTreeAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Request failed: STATUS ${response.statusCode}");
|
debug("Request failed: STATUS ${response.statusCode}");
|
||||||
|
|
||||||
|
// reset token
|
||||||
|
userProfile.token = "";
|
||||||
|
profile = userProfile;
|
||||||
|
} else {
|
||||||
|
// save token
|
||||||
|
await UserProfileDBManager().updateProfile(userProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue