Skip to content

Commit 71c9537

Browse files
committed
[FIX] Remove save password checkbox, new token saving system
1 parent 202be9e commit 71c9537

7 files changed

Lines changed: 15 additions & 73 deletions

File tree

runtime/scenes/login/login.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<Insets left="5.0" />
3939
</padding>
4040
</CheckBox>
41-
<CheckBox id="savePassword" prefHeight="18.0" prefWidth="276.0" text="%runtime.scenes.login.savePassword" wrapText="true">
41+
<CheckBox id="savePassword" prefHeight="18.0" prefWidth="276.0" text="%runtime.scenes.login.savePassword" visible="false" wrapText="true">
4242
<padding>
4343
<Insets left="5.0" />
4444
</padding>

src/main/java/pro/gravit/launcher/gui/components/BasicUserControls.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ protected void userExit() {
5050
(event) -> {
5151
// Exit to main menu
5252
ContextHelper.runInFxThreadStatic(() -> {
53-
application.gui.loginScene.clearPassword();
5453
application.gui.loginScene.reset();
5554
try {
5655
application.authService.exit();

src/main/java/pro/gravit/launcher/gui/core/config/RuntimeSettings.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,8 @@ public class RuntimeSettings extends UserSettings {
1616
public static final LAUNCHER_LOCALE DEFAULT_LOCALE = LAUNCHER_LOCALE.RUSSIAN;
1717
public transient Path updatesDir;
1818
@LauncherNetworkAPI
19-
public String login;
20-
@LauncherNetworkAPI
21-
public AuthMethodPassword password;
22-
@LauncherNetworkAPI
2319
public boolean autoAuth;
2420
@LauncherNetworkAPI
25-
public String lastAuth;
26-
@LauncherNetworkAPI
2721
public String updatesDirPath;
2822
@LauncherNetworkAPI
2923
public UUID lastProfile;

src/main/java/pro/gravit/launcher/gui/scenes/login/AuthFlow.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void loginWithGui() {
190190
}
191191

192192
// Пробуем тихую авторизацию только если токен есть И провайдер совпадает с сохранённым
193-
if (hasOAuthToken() && isSameAuthProvider()) {
193+
if (hasOAuthToken()) {
194194
tryAutoLogin().thenAccept(success -> {
195195
if (!success) {
196196
accessor.runInFxThread(() -> start().thenAccept((result) -> {
@@ -210,12 +210,6 @@ void loginWithGui() {
210210
});
211211
}
212212

213-
private boolean isSameAuthProvider() {
214-
String lastAuth = accessor.getApplication().runtimeSettings.lastAuth;
215-
if (lastAuth == null || authAvailability == null) return false;
216-
return lastAuth.equals(authAvailability.getName());
217-
}
218-
219213
private boolean hasOAuthToken() {
220214
UserSettings settings = LauncherBackendAPIHolder.getApi().getUserSettings("backend", (a) -> null);
221215
if (settings instanceof BackendSettings backendSettings) {

src/main/java/pro/gravit/launcher/gui/scenes/login/LoginScene.java

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class LoginScene extends FxScene {
3232
LoggerFactory.getLogger(LoginScene.class);
3333

3434
private List<AuthMethod> auth; //TODO: FIX? Field is assigned but never accessed.
35-
private CheckBox savePasswordCheckBox;
35+
//private CheckBox savePasswordCheckBox;
3636
private CheckBox autoenter;
3737
private Pane content;
3838
private UIComponent contentComponent;
@@ -58,13 +58,13 @@ public void doInit() {
5858
});
5959
authButton = use(layout, AuthButton::new);
6060
authButton.setOnAction((e) -> contextHelper.runCallback(authFlow::loginWithGui));
61-
savePasswordCheckBox = LookupHelper.lookup(layout, "#savePassword");
61+
//savePasswordCheckBox = LookupHelper.lookup(layout, "#savePassword");
6262
autoenter = LookupHelper.lookup(layout, "#autoenter");
6363
autoenter.setSelected(application.runtimeSettings.autoAuth);
6464
autoenter.setOnAction((event) -> application.runtimeSettings.autoAuth = autoenter.isSelected());
6565

6666
// Показываем галочку сохранения если есть логин или OAuth токен
67-
savePasswordCheckBox.setSelected(application.runtimeSettings.login != null || hasOAuthToken());
67+
/*savePasswordCheckBox.setSelected(application.runtimeSettings.login != null || hasOAuthToken());
6868
savePasswordCheckBox.setOnAction((event) -> {
6969
if (!savePasswordCheckBox.isSelected()) {
7070
application.runtimeSettings.login = null;
@@ -81,7 +81,7 @@ public void doInit() {
8181
}
8282
}
8383
}
84-
});
84+
});*/
8585

8686
content = LookupHelper.lookup(layout, "#content");
8787
if (application.guiModuleConfig.createAccountURL != null) {
@@ -109,12 +109,6 @@ private void clearOAuthToken() {
109109
// Конкретный способ очистки зависит от реализации LauncherBackendAPI
110110
}
111111
private void getAvailabilityAuth() {
112-
if (application.runtimeSettings.lastAuth == null) {
113-
UserSettings settings = LauncherBackendAPIHolder.getApi().getUserSettings("backend", (a) -> null);
114-
if (settings instanceof BackendSettings backendSettings) {
115-
backendSettings.auth = null;
116-
}
117-
}
118112
processing(application.backendCallbackService.initDataCallback,
119113
application.getTranslation("runtime.overlay.processing.text.launcher"),
120114
(initData) -> contextHelper.runInFxThread(() -> {
@@ -125,16 +119,14 @@ private void getAvailabilityAuth() {
125119
if (!authAvailability.isVisible()) {
126120
continue;
127121
}
128-
if (application.runtimeSettings.lastAuth == null) {
129-
if (authAvailability.getName().equals("std") || this.authAvailability == null) {
130-
changeAuthAvailability(authAvailability);
131-
}
132-
} else if (authAvailability.getName().equals(application.runtimeSettings.lastAuth))
133-
changeAuthAvailability(authAvailability);
134122
if(authAvailability.isVisible()) {
135123
addAuthAvailability(authAvailability);
136124
}
137125
}
126+
this.authAvailability = LauncherBackendAPIHolder.getApi().getAuthMethod();
127+
if(this.authAvailability != null) {
128+
changeAuthAvailability(this.authAvailability);
129+
}
138130
if (this.authAvailability == null && !auth.isEmpty()) {
139131
changeAuthAvailability(auth.get(0));
140132
}
@@ -153,11 +145,10 @@ private void runAutoAuth() {
153145
if (!shouldAutoAuth) return;
154146

155147
boolean hasOAuthToken = hasOAuthToken();
156-
boolean hasSavedPassword = application.runtimeSettings.password != null;
157148

158-
if (hasOAuthToken || hasSavedPassword) {
149+
if (hasOAuthToken) {
159150
authFlow.tryAutoLogin().thenAccept(success -> {
160-
if (!success && hasSavedPassword) {
151+
if (!success) {
161152
contextHelper.runInFxThread(authFlow::loginWithGui);
162153
}
163154
});
@@ -214,18 +205,7 @@ public String getName() {
214205
public void onSuccessLogin(AuthFlow.SuccessAuth successAuth) {
215206
var user = successAuth.user();
216207
application.authService.setUser(user);
217-
boolean savePassword = savePasswordCheckBox.isSelected();
218-
219-
if (savePassword) {
220-
application.runtimeSettings.login = successAuth.recentLogin();
221-
application.runtimeSettings.password = null;
222-
application.runtimeSettings.lastAuth = authAvailability.getName(); // сохраняем провайдер
223-
} else {
224-
// Галочки нет — очищаем всё включая провайдер
225-
application.runtimeSettings.login = null;
226-
application.runtimeSettings.password = null;
227-
application.runtimeSettings.lastAuth = null;
228-
}
208+
229209
if (user != null
230210
&& user.getAssets() != null) {
231211
try {
@@ -273,11 +253,6 @@ public void onGetProfiles() {
273253
}, null);
274254
}
275255

276-
public void clearPassword() {
277-
application.runtimeSettings.password = null;
278-
application.runtimeSettings.login = null;
279-
}
280-
281256
public AuthFlow getAuthFlow() {
282257
return authFlow;
283258
}

src/main/java/pro/gravit/launcher/gui/scenes/login/methods/LoginAndPasswordAuthMethod.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ public CompletableFuture<AuthFlow.LoginAndPasswordResult> auth(AuthPasswordDetai
6363
overlay.future = new CompletableFuture<>();
6464
String login = overlay.login.getText();
6565
AuthMethodPassword password;
66-
if (overlay.password.getText().isEmpty() && overlay.password.getPromptText().equals(application.getTranslation(
67-
"runtime.scenes.login.password.saved"))) {
68-
password = application.runtimeSettings.password;
69-
return CompletableFuture.completedFuture(new AuthFlow.LoginAndPasswordResult(login, password));
70-
}
7166
return overlay.future;
7267
}
7368

@@ -120,17 +115,7 @@ protected void doInit() {
120115
login.textProperty().addListener(l -> accessor.getAuthButton().setState(login.getText().isEmpty()
121116
? AuthButton.AuthButtonState.UNACTIVE
122117
: AuthButton.AuthButtonState.ACTIVE));
123-
124-
if (application.runtimeSettings.login != null) {
125-
login.setText(application.runtimeSettings.login);
126-
accessor.getAuthButton().setState(AuthButton.AuthButtonState.ACTIVE);
127-
} else {
128-
accessor.getAuthButton().setState(AuthButton.AuthButtonState.UNACTIVE);
129-
}
130-
if (application.runtimeSettings.password != null) {
131-
password.getStyleClass().add("hasSaved");
132-
password.setPromptText(application.getTranslation("runtime.scenes.login.password.saved"));
133-
}
118+
accessor.getAuthButton().setState(AuthButton.AuthButtonState.UNACTIVE);
134119
}
135120

136121
@Override

src/main/java/pro/gravit/launcher/gui/scenes/login/methods/LoginOnlyAuthMethod.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,7 @@ protected void doInit() {
110110
login.textProperty().addListener(l -> accessor.getAuthButton().setState(login.getText().isEmpty()
111111
? AuthButton.AuthButtonState.UNACTIVE
112112
: AuthButton.AuthButtonState.ACTIVE));
113-
if (application.runtimeSettings.login != null) {
114-
login.setText(application.runtimeSettings.login);
115-
accessor.getAuthButton().setState(AuthButton.AuthButtonState.ACTIVE);
116-
} else {
117-
accessor.getAuthButton().setState(AuthButton.AuthButtonState.UNACTIVE);
118-
}
113+
accessor.getAuthButton().setState(AuthButton.AuthButtonState.UNACTIVE);
119114
}
120115

121116
@Override

0 commit comments

Comments
 (0)