Fix unnecessary authentication token being sent in requests
This commit is contained in:
@ -21,7 +21,6 @@
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
|
@ -44,7 +44,6 @@ public final class LocalDB implements EventListener {
|
||||
private IDGenerator idGenerator;
|
||||
private CacheMap cacheMap = new CacheMap();
|
||||
private String authToken;
|
||||
private boolean saveToken;
|
||||
private boolean contactsChanged;
|
||||
|
||||
// Auto save timer
|
||||
@ -261,7 +260,7 @@ public final class LocalDB implements EventListener {
|
||||
Context.getInstance().getClient().isOnline() ? Instant.now() : lastSync);
|
||||
|
||||
// Save last login information
|
||||
if (saveToken && authToken != null)
|
||||
if (authToken != null)
|
||||
SerializationUtils.write(lastLoginFile, user, authToken);
|
||||
|
||||
// Save ID generator
|
||||
@ -489,10 +488,4 @@ public final class LocalDB implements EventListener {
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public String getAuthToken() { return authToken; }
|
||||
|
||||
/**
|
||||
* @param saveToken whether the token will be persisted or deleted on shutdown
|
||||
* @since Envoy Client v0.3-beta
|
||||
*/
|
||||
public void setSaveToken(boolean saveToken) { this.saveToken = saveToken; }
|
||||
}
|
||||
|
@ -153,8 +153,7 @@ public final class Client implements EventListener, Closeable {
|
||||
try {
|
||||
SerializationUtils.writeBytesWithLength(
|
||||
new AuthenticatedRequest<>(obj,
|
||||
Context.getInstance().getLocalDB().getUser().getID(),
|
||||
Context.getInstance().getLocalDB().getAuthToken()),
|
||||
Context.getInstance().getLocalDB().getUser().getID()),
|
||||
socket.getOutputStream());
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -16,7 +16,7 @@ import envoy.data.LoginCredentials;
|
||||
import envoy.event.HandshakeRejection;
|
||||
import envoy.util.*;
|
||||
|
||||
import envoy.client.data.*;
|
||||
import envoy.client.data.ClientConfig;
|
||||
import envoy.client.ui.Startup;
|
||||
import envoy.client.util.IconUtil;
|
||||
|
||||
@ -79,11 +79,9 @@ public final class LoginScene implements EventListener {
|
||||
|
||||
@FXML
|
||||
private void loginButtonPressed() {
|
||||
final String user = userTextField.getText(), pass = passwordField.getText(),
|
||||
final String user = userTextField.getText(), pass = passwordField.getText(),
|
||||
repeatPass = repeatPasswordField.getText();
|
||||
|
||||
// Choose whether to persist the token or not
|
||||
Context.getInstance().getLocalDB().setSaveToken(cbStaySignedIn.isSelected());
|
||||
final boolean requestToken = cbStaySignedIn.isSelected();
|
||||
|
||||
// Prevent registration with unequal passwords
|
||||
if (registration && !pass.equals(repeatPass)) {
|
||||
@ -98,8 +96,8 @@ public final class LoginScene implements EventListener {
|
||||
} else {
|
||||
Instant lastSync = Startup.loadLastSync(userTextField.getText());
|
||||
Startup.performHandshake(registration
|
||||
? LoginCredentials.registration(user, pass, Startup.VERSION, lastSync)
|
||||
: LoginCredentials.login(user, pass, Startup.VERSION, lastSync));
|
||||
? LoginCredentials.registration(user, pass, requestToken, Startup.VERSION, lastSync)
|
||||
: LoginCredentials.login(user, pass, requestToken, Startup.VERSION, lastSync));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user