Skip to content

Commit

Permalink
support httpLogout
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvergnaud committed Jun 11, 2020
1 parent 4a1d7ce commit 14c55a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Server/src/main/java/prompto/server/AppServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.server.handler.HandlerList;
Expand Down Expand Up @@ -279,4 +280,11 @@ public static void httpRedirect(String path) throws IOException {
response.sendRedirect(path);
}


/* used by Server.pec */
public static void httpLogout(String path) throws IOException {
HttpServletRequest request = CleverServlet.CURRENT_REQUEST.get();
request.getSession().invalidate();
httpRedirect(path);
}
}
4 changes: 4 additions & 0 deletions Server/src/main/resources/libraries/Server.pec
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ define getHttpUser as native method returning Text doing:
define getHttpSession as native method returning Document doing:
Java: return $server.getHttpSession();

define httpLogout as native method receiving Text path doing:
Java: $server.httpLogout(path);

define getHttpPort as native method returning Integer doing:
Java: return $server.getHttpPort();
JavaScript: return self.location.port;

define httpRedirect as native method receiving Text path doing:
Java: $server.httpRedirect(path);
JavaScript: browserGoto(location); from module: prompto/internet/Browser.js

0 comments on commit 14c55a4

Please sign in to comment.