Reset server preferences on login error

This commit is contained in:
CappielloAntonio 2022-02-06 16:36:10 +01:00
parent acf8525cfd
commit bc6fc5be0f
2 changed files with 12 additions and 1 deletions

View file

@ -93,6 +93,7 @@ public class ServerAdapter extends RecyclerView.Adapter<ServerAdapter.ViewHolder
systemRepository.checkUserCredential(new SystemCallback() {
@Override
public void onError(Exception exception) {
resetServerPreference();
Toast.makeText(context, exception.getMessage(), Toast.LENGTH_SHORT).show();
}
@ -128,5 +129,15 @@ public class ServerAdapter extends RecyclerView.Adapter<ServerAdapter.ViewHolder
App.getSubsonicClientInstance(context, true);
}
private void resetServerPreference() {
PreferenceUtil.getInstance(context).setServerId(null);
PreferenceUtil.getInstance(context).setServer(null);
PreferenceUtil.getInstance(context).setUser(null);
PreferenceUtil.getInstance(context).setPassword(null);
PreferenceUtil.getInstance(context).setLowSecurity(false);
App.getSubsonicClientInstance(context, true);
}
}
}