Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Logout function

  • Loading branch information...
commit b3d98ab44e066abe0b8920c45309a4143b99b2fb 1 parent 1b655ce
thomasvoelk authored
5 java/src/org/voelk/holidays/web/GaeAuthenticator.java
View
@@ -13,9 +13,8 @@ public GaeAuthenticator(Context context, ChallengeScheme challengeScheme, String
@Override
protected boolean authenticate(Request request, Response response) {
if (!UserServiceFactory.getUserService().isUserLoggedIn()) {
- String path = request.getOriginalRef().getPath();
- String loginURL = UserServiceFactory.getUserService().createLoginURL(path);
- response.redirectTemporary(loginURL);
+ String loginUrl = UserServiceFactory.getUserService().createLoginURL(request.getOriginalRef().getPath());
+ response.redirectTemporary(loginUrl);
return false;
} else {
return true;
6 java/src/org/voelk/holidays/web/pages/PageResource.java
View
@@ -1,5 +1,6 @@
package org.voelk.holidays.web.pages;
+import com.google.appengine.api.users.*;
import org.restlet.data.*;
import org.restlet.ext.freemarker.*;
import org.restlet.representation.*;
@@ -21,9 +22,8 @@ public Representation toHtml() {
protected Map<String, Object> createPageData() {
Map<String, Object> ret = getPageData();
-// String s1 = getRequest().getRootRef().getPath();
-// String s2 = getRequest().getRootRef().toString();
-// ret.put("pageContext", s1);
+ ret.put("logoutUrl", UserServiceFactory.getUserService().createLogoutURL("/index.html"));
+ ret.put("userIsLoggedIn", UserServiceFactory.getUserService().isUserLoggedIn());
return ret;
}
1  web/WEB-INF/appengine-web.xml
View
@@ -9,5 +9,6 @@
<include path="/css/**.css"/>
<include path="/js/**.js"/>
<include path="/favicon.ico"/>
+ <include path="/index.html"/>
</static-files>
</appengine-web-app>
5 web/WEB-INF/templates/pages/basePage.ftl
View
@@ -1,3 +1,5 @@
+<#-- @ftlvariable name="userIsLoggedIn" type="boolean" -->
+<#-- @ftlvariable name="logoutUrl" type="java.lang.String" -->
<#macro page>
<!DOCTYPE html>
<html>
@@ -24,6 +26,9 @@
FeedbackOptions.planboxToken = '732647a147763a25c3c135dc87a90282';
FeedbackOptions.dialogTitle = 'Tell us what you think';
</script>
+ <#if userIsLoggedIn>
+ <a href="${logoutUrl}">Logout</a>
+ </#if>
<div id="content">
<#nested/>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.