Commit 72c5145d authored by wannes's avatar wannes
Browse files

Reflect DB field name change (user_id -> userId)

parent 789f28ff
......@@ -46,7 +46,7 @@ public class Client implements OwnedEntity, Serializable {
User user = users.get(0);
HashMap<String, Object> query = new HashMap<>();
query.put("user_id", user.id);
query.put("userId", user.id);
query.put("commonName", vpnClient.commonName);
List<Client> clients = Clients.dao.queryForFieldValues(query);
......
......@@ -77,7 +77,7 @@ public class IPAddresses {
public static List<IPAddress> forUser(UUID userId, int ipVersion) {
try {
ArrayList<IPAddress> addrs = new ArrayList<>();
List<Client> clients = Clients.dao.queryForEq("user_id", "" + userId);
List<Client> clients = Clients.dao.queryForEq("userId", UUID.fromString("" + userId));
for (Client client : clients) {
addrs.addAll(client.leases);
}
......
......@@ -60,7 +60,7 @@ public class UserRegistration extends ResourceBase {
// Legacy fix
if (reg.client == null) {
reg.client = Clients.dao.queryForEq("user_id", reg.user).get(0);
reg.client = Clients.dao.queryForEq("userId", reg.user).get(0);
}
} catch (SQLException ex) {
......
......@@ -13,6 +13,7 @@ import org.restlet.resource.Post;
import org.restlet.resource.Put;
import java.util.List;
import java.util.UUID;
/**
* Created by wannes on 11/10/14.
......@@ -69,11 +70,16 @@ public class VPNClient extends ResourceBase {
List<Client> clients;
if (getQueryValue("user") != null)
clients = Clients.dao.queryForEq("user_id", getQueryValue("user"));
clients = Clients.dao.queryForEq("userId", UUID.fromString(getQueryValue("user")));
else
clients = Clients.dao.queryForAll();
clients = Policy.filterAccessible(getSessionToken().get().getUser(), clients);
if (getQueryValue("compose") != null) {
clients.forEach(Client::user);
}
return new JacksonRepresentation<>(clients);
} catch (Exception ex) {
Logger.getLogger(getClass()).error("Failed to retrieve clients", ex);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment