use of net.runelite.http.service.account.beans.SessionEntry in project runelite by runelite.
the class AuthFilter method handle.
public SessionEntry handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
String runeliteAuth = request.getHeader(RuneLiteAPI.RUNELITE_AUTH);
if (runeliteAuth == null) {
response.sendError(401, "Access denied");
return null;
}
UUID uuid = UUID.fromString(runeliteAuth);
try (Connection con = sql2o.open()) {
SessionEntry sessionEntry = con.createQuery("select user, uuid, created from sessions where uuid = :uuid").addParameter("uuid", uuid.toString()).executeAndFetchFirst(SessionEntry.class);
if (sessionEntry == null) {
response.sendError(401, "Access denied");
return null;
}
Instant now = Instant.now();
con.createQuery("update sessions set last_used = :last_used where uuid = :uuid").addParameter("last_used", Timestamp.from(now)).addParameter("uuid", uuid.toString()).executeUpdate();
sessionEntry.setLastUsed(now);
return sessionEntry;
}
}
use of net.runelite.http.service.account.beans.SessionEntry in project runelite by runelite.
the class ConfigService method get.
@RequestMapping
public Configuration get(HttpServletRequest request, HttpServletResponse response) throws IOException {
SessionEntry session = auth.handle(request, response);
if (session == null) {
return null;
}
List<ConfigEntry> config;
try (Connection con = sql2o.open()) {
config = con.createQuery("select `key`, value from config where user = :user").addParameter("user", session.getUser()).executeAndFetch(ConfigEntry.class);
}
return new Configuration(config);
}
Aggregations