You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/02/09 17:29:22 UTC

svn commit: r505353 - /lenya/trunk/src/modules-core/acusecases/java/src/org/apache/lenya/cms/ac/usecases/Login.java

Author: andreas
Date: Fri Feb  9 08:29:22 2007
New Revision: 505353

URL: http://svn.apache.org/viewvc?view=rev&rev=505353
Log:
Move authentication from execute() to checkExecutionConditions() to avoid duplicate usecase execution

Modified:
    lenya/trunk/src/modules-core/acusecases/java/src/org/apache/lenya/cms/ac/usecases/Login.java

Modified: lenya/trunk/src/modules-core/acusecases/java/src/org/apache/lenya/cms/ac/usecases/Login.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/acusecases/java/src/org/apache/lenya/cms/ac/usecases/Login.java?view=diff&rev=505353&r1=505352&r2=505353
==============================================================================
--- lenya/trunk/src/modules-core/acusecases/java/src/org/apache/lenya/cms/ac/usecases/Login.java (original)
+++ lenya/trunk/src/modules-core/acusecases/java/src/org/apache/lenya/cms/ac/usecases/Login.java Fri Feb  9 08:29:22 2007
@@ -50,13 +50,12 @@
         Publication publication;
 
         try {
-            publication = PublicationUtil.getPublicationFromUrl(this.manager,
-                    getDocumentFactory(),
+            publication = PublicationUtil.getPublicationFromUrl(this.manager, getDocumentFactory(),
                     getSourceURL());
             if (publication.exists()) {
                 setParameter(PUBLICATION_ID, publication.getId());
             }
-            Identity identity = this.getSession().getIdentity(); 
+            Identity identity = this.getSession().getIdentity();
             if (identity != null && identity.getUser() != null) {
                 setParameter(CURRENT_USER, this.getSession().getIdentity().getUser());
             }
@@ -87,27 +86,26 @@
         if (password.length() == 0) {
             addErrorMessage("Please enter a password.");
         }
+
     }
 
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
      */
     protected void doCheckExecutionConditions() throws Exception {
+        
         validate();
-    }
-
-    /**
-     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
-     */
-    protected void doExecute() throws Exception {
-        Map objectModel = ContextHelper.getObjectModel(getContext());
-        Request request = ObjectModelHelper.getRequest(objectModel);
-        request.getSession(true);
-        if (getAccessController().authenticate(request)) {
-            request.getSession(false).removeAttribute(HISTORY_SESSION_ATTRIBUTE);
-            setDefaultTargetURL(request.getPathInfo());
-        } else {
-            addErrorMessage("Authentication failed");
+        
+        if (!hasErrors()) {
+            Map objectModel = ContextHelper.getObjectModel(getContext());
+            Request request = ObjectModelHelper.getRequest(objectModel);
+            request.getSession(true);
+            if (getAccessController().authenticate(request)) {
+                request.getSession(false).removeAttribute(HISTORY_SESSION_ATTRIBUTE);
+                setDefaultTargetURL(request.getPathInfo());
+            } else {
+                addErrorMessage("Authentication failed");
+            }
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org