parent
6d4bb5dcbc
commit
33c88ec9e4
|
@ -27,6 +27,7 @@ import org.whispersystems.textsecuregcm.storage.Account;
|
||||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||||
import org.whispersystems.textsecuregcm.storage.Device;
|
import org.whispersystems.textsecuregcm.storage.Device;
|
||||||
import org.whispersystems.textsecuregcm.util.Constants;
|
import org.whispersystems.textsecuregcm.util.Constants;
|
||||||
|
import org.whispersystems.textsecuregcm.util.Util;
|
||||||
|
|
||||||
import static com.codahale.metrics.MetricRegistry.name;
|
import static com.codahale.metrics.MetricRegistry.name;
|
||||||
import io.dropwizard.auth.AuthenticationException;
|
import io.dropwizard.auth.AuthenticationException;
|
||||||
|
@ -67,6 +68,7 @@ public class AccountAuthenticator implements Authenticator<BasicCredentials, Acc
|
||||||
if (device.get().getAuthenticationCredentials().verify(basicCredentials.getPassword())) {
|
if (device.get().getAuthenticationCredentials().verify(basicCredentials.getPassword())) {
|
||||||
authenticationSucceededMeter.mark();
|
authenticationSucceededMeter.mark();
|
||||||
account.get().setAuthenticatedDevice(device.get());
|
account.get().setAuthenticatedDevice(device.get());
|
||||||
|
updateLastSeen(account.get(), device.get());
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,4 +78,12 @@ public class AccountAuthenticator implements Authenticator<BasicCredentials, Acc
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateLastSeen(Account account, Device device) {
|
||||||
|
if (device.getLastSeen() != Util.todayInMillis()) {
|
||||||
|
device.setLastSeen(Util.todayInMillis());
|
||||||
|
accountsManager.update(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class AuthenticatedConnectListener implements WebSocketConnectListener {
|
||||||
context.getClient());
|
context.getClient());
|
||||||
|
|
||||||
pubSubManager.publish(info, PubSubMessage.newBuilder().setType(PubSubMessage.Type.CONNECTED).build());
|
pubSubManager.publish(info, PubSubMessage.newBuilder().setType(PubSubMessage.Type.CONNECTED).build());
|
||||||
updateLastSeen(account, device);
|
|
||||||
pubSubManager.subscribe(address, connection);
|
pubSubManager.subscribe(address, connection);
|
||||||
|
|
||||||
context.addListener(new WebSocketSessionContext.WebSocketEventListener() {
|
context.addListener(new WebSocketSessionContext.WebSocketEventListener() {
|
||||||
|
@ -66,12 +65,5 @@ public class AuthenticatedConnectListener implements WebSocketConnectListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLastSeen(Account account, Device device) {
|
|
||||||
if (device.getLastSeen() != Util.todayInMillis()) {
|
|
||||||
device.setLastSeen(Util.todayInMillis());
|
|
||||||
accountsManager.update(account);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue