gracefully handle user_not_found

This commit is contained in:
Mike Schwörer 2018-11-12 14:10:35 +01:00
parent 92ac05f1e3
commit 3d29fecaec
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 23 additions and 2 deletions

View File

@ -246,8 +246,27 @@ public class ServerCommunication
JSONObject json = (JSONObject) new JSONTokener(r).nextValue(); JSONObject json = (JSONObject) new JSONTokener(r).nextValue();
if (!json.getBoolean("success")) { if (!json.getBoolean("success"))
{
SCNApp.showToast(json.getString("message"), 4000); SCNApp.showToast(json.getString("message"), 4000);
int errid = json.optInt("errid", 0);
if (errid == 201 || errid == 202 || errid == 203 || errid == 204)
{
// user not found or auth failed
SCNSettings.inst().user_id = -1;
SCNSettings.inst().user_key = "";
SCNSettings.inst().quota_curr = 0;
SCNSettings.inst().quota_max = 0;
SCNSettings.inst().promode_server = false;
SCNSettings.inst().fcm_token_server = "";
SCNSettings.inst().save();
SCNApp.refreshAccountTab();
}
return; return;
} }

View File

@ -1,3 +1,4 @@
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` CREATE TABLE `users`
( (
`user_id` INT(11) NOT NULL AUTO_INCREMENT, `user_id` INT(11) NOT NULL AUTO_INCREMENT,
@ -16,6 +17,7 @@ CREATE TABLE `users`
PRIMARY KEY (`user_id`) PRIMARY KEY (`user_id`)
); );
DROP TABLE IF EXISTS `messages`;
CREATE TABLE `messages` CREATE TABLE `messages`
( (
`scn_message_id` INT(11) NOT NULL AUTO_INCREMENT, `scn_message_id` INT(11) NOT NULL AUTO_INCREMENT,
@ -31,4 +33,4 @@ CREATE TABLE `messages`
`usr_message_id` VARCHAR(256) NULL, `usr_message_id` VARCHAR(256) NULL,
PRIMARY KEY (`scn_message_id`) PRIMARY KEY (`scn_message_id`)
) );