cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Haul <h...@dvs1.informatik.tu-darmstadt.de>
Subject Re: FW: Separation of logic/content (Was: XSP Best Practise Question)
Date Fri, 23 Aug 2002 08:17:43 GMT
On 23.Aug.2002 -- 08:41 AM, Morrison, John wrote:
> I think Alan has some good points.  Forwarded to cocoon-dev from -user.

You should definitely have a look at the flow as present in 2.1-dev
thanks to Ovidiu and Christopher. It has still some problems, but it
is much like having this single servlet.

I'm currently over a deadline so I'll just throw some code at you that
might illustrate use. When finished, cleaned up, and documented I plan
to put the whole thing up, either in applications or somewhere else on
the net.

*WARNING* The following is ugly code and if you might be offended by
such work, don't look at it. *WARNING*


The following is JavaScript code invoked through the sitemap using 

    <map:resource name="flow">
	  <!-- flow script -->
      <map:script src="flow.js"/>
    </map:resource>

	<map:resource name="function">
	  <!-- invoke a JavaScript flow function -->
	  <map:call function="{target}">
		<map:parameter name="prefix" value="{vquadrat-def:base-url}/protected/admin/internal"/>
	  </map:call>
	</map:resource>

in addition, the following is needed:

      <map:match pattern="kont/*">
		<!-- protected continuations -->
        <map:continue with="{1}"/>
	  </map:match>


Documentation is currently very sparse, but this is (pre-)alpha
anyway. There is a samll but complete example in the 2.1-dev snapshots.

function login(uriPrefix){
  var i;
  var j;
  var validation;
  var validation2;
  var msg;
  var tmp;
  var tmp2;
  var destination;
  var menuitem = "login";

  prefix=uriPrefix.slice(uriPrefix.indexOf('/',1));
  
  // save original destination from request-URI
  destination = inputValue("URI", "");
  log.debug("original destination is "+destination);
  log.debug("original destination == 'login' "+(destination=="login"));
  log.debug("original destination indexOf('protected/') "+destination.indexOf("protected/"));
  if (destination == "login" || destination.indexOf("protected/") == -1) {
    destination = "protected/welcome";
  } else if (destination.lastIndexOf("/logout")==destination.length-"/logout".length) {
    destination = "login";
  } 
  log.debug("destination is "+destination);
  

  i = 0;
  j = 0;
  msg = "";
  do {
    i++;
    validation = null;
    validation2 = null;
    tmp = inputValue("vquadrat-constants","base-url")+"/internal/login";
    tmp2 = inputValue("vquadrat-constants","base-url")+"/internal_new/login";

    do {
      // send login page
      if (j==0) {
        mySendPage(tmp2,{}, menuitem);
        j++;
      } else {
        mySendPage(tmp,{}, menuitem);
      }
      validation = act("vq-validator","",{"validate-set":"login"});
      log.debug("validation = "+(validation==null? "null" : validation));
    } while (validation == null);

    // check if account is blocked
    validation2 = act("vq-dbquery","",{"table-set":"is-not-blocked"});
    log.debug("account blocked? validation2 = "+(validation2==null? "null" : validation2));
    if (validation2 == null) {
      msg="The system could not log you in. Your account may have been blocked now for some
minutes.";
      validation = null;
    } else {
      msg="";
      // check if password is ok
      validation = act("vq-dbsel","",{"table-set":"login"});
      log.debug("passwd ok? validation = "+(validation==null? "null" : validation));
      if (validation == null) {
      // login failed, block account
        msg="The system could not log you in. Your account may have been blocked now for some
minutes.";
        validation2 = act("vq-dbquery","",{"table-set":"block-login"});
        log.debug("lock! validation2 = "+(validation2==null? "null" : validation2));
      } else {
        // login OK, set session attribute / clear failcount
        outputSet("vq-session","userdata", validation);
        outputSet("vq-session","logged-in", "true");
        outputCommit("vq-session");
        validation = act("vq-dbquery","",{"table-set":"block-clear"});
        log.debug("reset lock? validation = "+(validation==null? "null" : validation));
      }
    }
  } while((i<5)&&(validation==null));

  // send original destination
  mySendPage(destination,{}, menuitem);

  // done
}


	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message