Skip to content

Commit

Permalink
Merge branch 'react-tomcat9' of https://github.com/WildMeOrg/Wildbook
Browse files Browse the repository at this point in the history
…into react-tomcat9
  • Loading branch information
erinz2020 committed Mar 14, 2024
2 parents 3e0c028 + 824ed64 commit afb6c8b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/main/java/org/ecocean/api/UserInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,34 @@

public class UserInfo extends ApiBase {

// for polling we do a simple HEAD response
protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String context = ServletUtilities.getContext(request);
Shepherd myShepherd = new Shepherd(context);
myShepherd.setAction("api.UserInfo.HEAD");
myShepherd.beginDBTransaction();

User currentUser = myShepherd.getUser(request);
if (currentUser == null) {
response.setStatus(401);
//response.setHeader("Content-Type", "application/json");
//response.getWriter().write("{\"success\": false}");
myShepherd.rollbackDBTransaction();
myShepherd.closeDBTransaction();
return;
}

response.setStatus(200);
response.setHeader("X-User-Id", currentUser.getId());
// TODO could also set: notification stuff? login time? etc?
myShepherd.rollbackDBTransaction();
myShepherd.closeDBTransaction();
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String context = ServletUtilities.getContext(request);
Shepherd myShepherd = new Shepherd(context);
myShepherd.setAction("api.UserInfo");
myShepherd.setAction("api.UserInfo.GET");
myShepherd.beginDBTransaction();

User currentUser = myShepherd.getUser(request);
Expand Down

0 comments on commit afb6c8b

Please sign in to comment.