<?xml version="1.0"?>
<?xml-stylesheet href="NULL" type="application/x-xsp"?>
<?xml-stylesheet href="/transforms/xhtml/login.xsl" type="text/xsl"?>

<xsp:page language="Perl"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  xmlns:cust="http://www.kjetil.kjernsmo.net/software/TABOO/NS/CustomGrammar"
  xmlns:i18n="http://www.kjetil.kjernsmo.net/software/TABOO/NS/I18N"
  xmlns:auth="http://www.nichework.com/2003/XSP/BasicAuth"
  xmlns:session="http://www.axkit.org/2002/XSP/BasicSession"
  xmlns:user="http://www.kjetil.kjernsmo.net/software/TABOO/NS/User"
  xmlns:param="http://www.axkit.org/2002/XSP/QueryParam"
  xmlns="http://www.w3.org/1999/xhtml">
  <cust:loginpage>
    <user:exists>
      <user:username><param:get name="credential_0"/></user:username>
      <user:true>
	<user:password-matches>
	  <user:username><param:get name="credential_0"/></user:username>
	  <user:clear><param:get name="passwd"/></user:clear>
	  <user:true>
	    <!-- In here, everything is OK, and we log the user in,
	    after first invalidating any other sessions. -->
	    <xsp:logic><session:invalidate/>;<auth:login/>;
	      <session:set-attribute name="authlevel">
		<session:value><user:get-authlevel><user:username><param:get name="credential_0"/></user:username></user:get-authlevel></session:value>
	      </session:set-attribute>;</xsp:logic>
	    <i18n:insert>password-valid</i18n:insert>
	  </user:true>
	  <user:false><i18n:insert>password-invalid</i18n:insert></user:false>
	</user:password-matches>
      </user:true>
      <user:false>
	<i18n:insert>username-not-found</i18n:insert>
      </user:false>
    </user:exists>
  </cust:loginpage>
</xsp:page>
