Fix ALL the logging!
[Sone.git] / src / main / java / net / pterodactylus / sone / web / LoginPage.java
index 10f1f9f..6f43b6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * FreenetSone - LoginPage.java - Copyright © 2010 David Roden
+ * Sone - LoginPage.java - Copyright © 2010 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,10 +24,11 @@ import java.util.logging.Logger;
 
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 import freenet.clients.http.ToadletContext;
 
 /**
@@ -61,7 +62,7 @@ public class LoginPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                /* get all own identities. */
                List<Sone> localSones = new ArrayList<Sone>(webInterface.getCore().getLocalSones());
@@ -72,7 +73,11 @@ public class LoginPage extends SoneTemplatePage {
                        Sone selectedSone = webInterface.getCore().getLocalSone(soneId, false);
                        if (selectedSone != null) {
                                setCurrentSone(request.getToadletContext(), selectedSone);
-                               throw new RedirectException("index.html");
+                               String target = request.getHttpRequest().getParam("target");
+                               if ((target == null) || (target.length() == 0)) {
+                                       target = "index.html";
+                               }
+                               throw new RedirectException(target);
                        }
                }
                List<OwnIdentity> ownIdentitiesWithoutSone = CreateSonePage.getOwnIdentitiesWithoutSone(webInterface.getCore());
@@ -83,8 +88,8 @@ public class LoginPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
-       protected String getRedirectTarget(Request request) {
-               if (getCurrentSone(request.getToadletContext()) != null) {
+       protected String getRedirectTarget(FreenetRequest request) {
+               if (getCurrentSone(request.getToadletContext(), false) != null) {
                        return "index.html";
                }
                return null;
@@ -99,7 +104,10 @@ public class LoginPage extends SoneTemplatePage {
         */
        @Override
        public boolean isEnabled(ToadletContext toadletContext) {
-               return getCurrentSone(toadletContext) == null;
+               if (webInterface.getCore().getPreferences().isRequireFullAccess() && !toadletContext.isAllowedFullAccess()) {
+                       return false;
+               }
+               return getCurrentSone(toadletContext, false) == null;
        }
 
 }