Fixed saving password on logging in unsecured mode

This commit is contained in:
CappielloAntonio 2022-01-11 15:50:22 +01:00
parent 2e8f8bd7b6
commit 1fce57e119
7 changed files with 31 additions and 16 deletions

View file

@ -96,7 +96,7 @@ public class MainActivity extends BaseActivity {
initBottomSheet();
initNavigation();
if (PreferenceUtil.getInstance(this).getToken() != null) {
if (PreferenceUtil.getInstance(this).getToken() != null && PreferenceUtil.getInstance(this).getSalt() != null) {
goFromLogin();
} else {
goToLogin();

View file

@ -148,8 +148,8 @@ public class ServerSignupDialog extends DialogFragment {
}
@Override
public void onSuccess(String token, String salt) {
saveServerPreference(null, null, null, token, salt);
public void onSuccess(String password, String token, String salt) {
saveServerPreference(null, null, password, token, salt);
if (directAccess) enter();
}
});
@ -167,13 +167,12 @@ public class ServerSignupDialog extends DialogFragment {
if (token != null && salt != null) {
String serverID = loginViewModel.getServerToEdit() != null ? loginViewModel.getServerToEdit().getServerId() : UUID.randomUUID().toString();
PreferenceUtil.getInstance(context).setPassword(this.lowSecurity ? password : null);
PreferenceUtil.getInstance(context).setToken(token);
PreferenceUtil.getInstance(context).setSalt(salt);
PreferenceUtil.getInstance(context).setServerId(serverID);
if (!lowSecurity) PreferenceUtil.getInstance(context).setPassword(null);
loginViewModel.addServer(new Server(serverID, this.serverName, this.username, this.server, token, salt, System.currentTimeMillis(), this.lowSecurity));
loginViewModel.addServer(new Server(serverID, this.serverName, this.username, this.lowSecurity ? password : null, this.server, token, salt, System.currentTimeMillis(), this.lowSecurity));
}
App.getSubsonicClientInstance(context, true);