Move login requirement to SoneTemplatePage.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / CreateSonePage.java
index 81f1c34..f977556 100644 (file)
@@ -47,7 +47,7 @@ public class CreateSonePage extends SoneTemplatePage {
         *            The Sone web interface
         */
        public CreateSonePage(Template template, WebInterface webInterface) {
-               super("createSone.html", template, "Page.CreateSone.Title", webInterface);
+               super("createSone.html", template, "Page.CreateSone.Title", webInterface, false);
        }
 
        //
@@ -59,6 +59,7 @@ public class CreateSonePage extends SoneTemplatePage {
         */
        @Override
        protected void processTemplate(Request request, Template template) throws RedirectException {
+               super.processTemplate(request, template);
                String name = "";
                String requestUri = null;
                String insertUri = null;
@@ -70,7 +71,7 @@ public class CreateSonePage extends SoneTemplatePage {
                        }
                        try {
                                /* create Sone. */
-                               Sone sone = webInterface.core().createSone(name, requestUri, insertUri);
+                               Sone sone = webInterface.core().createSone(name, "Sone", requestUri, insertUri);
 
                                /* log in the new Sone. */
                                setCurrentSone(request.getToadletContext(), sone);
@@ -94,7 +95,7 @@ public class CreateSonePage extends SoneTemplatePage {
         */
        @Override
        public boolean isEnabled(ToadletContext toadletContext) {
-               return true;
+               return getCurrentSone(toadletContext) == null;
        }
 
 }