I am trying to implement the following functionality within RIFE:

(1) User logs in to site with username/password.
(2) There is additional information about users held in a Postgresql database table. A user can have one or more roles, each of which can be associated with an area. Multiple roles are possible within the same area. So, once the user is logged in (and globalvar "authid" is set), I want to be able to do one of the following:

(a) If the user has a unique role/area combination, take them to the home page for their user type. No problem (and this works fine).

(b) If the user has >1 role, put up a form with a select list and a button to enable them to pick which role they want to perform.

I have implemented the role/area chooser as an embedded element of "home", just as I have the login box (as per the numberguess example). This is so that every subsequent template in the site can embed these elements which will tell the user who they're logged in as and what role they have in which area. The role and area will be set as globalvars "roleid" and "aaid".

The embedded elements perform as expected up to a point. The login screen comes up, I log in and it correctly reports who I am. When I have multiple roles it correctly outputs the form to enable me to select roles. The form submission points back to the parent element "home". I believe this from my reading of the manual to be correct.

The maddening thing that happens when I select my role and click the submit button is that I'm returned to the login box once more. The "authid" globalvar has somehow been lost as a result of doing the submission within the embedded element. I can't see what I'm doing wrong, and have gotten totally confused by this. I don't see how I can debug it either. I assume something in one or more of my XML files is wrong, but I have really got stuck as to what.

site file:
--------------------------------------------------------------------
<site>
    <globalvar name="authid"/>
    <globalvar name="roleid"/>
    <globalvar name="aaid"/>
    <arrival destid="HOME"/>
    <departure srcid="LOGOUT"/>
    <element id="AUTH" file="auth.xml"/>
<element id="LOGOUT" file="rife/logout/passthrough/database.xml" url="/logout"> <property name="datasource"><datasource>postgresql_live</datasource></property>
        <flowlink srcexit="logged_out" snapback="true"/>
    </element>
    <element id="LOGIN_BOX" file="credentials.xml" inherits="AUTH">
        <flowlink srcexit="logout" destid="LOGOUT"/>
    </element>
    <element id="ROLE_AREA_CHOOSER" file="roleareachooser.xml">
    </element>
    <element id="HOME" file="home.xml" url="/home">
        <property name="template_name">home</property>
        <exit name="register"/>
        <exit name="forgot_password"/>
        <flowlink srcexit="register" destid="REGISTER"/>
        <flowlink srcexit="forgot_password" destid="FORGOT_PASSWORD"/>
    </element>
    <element id="REGISTER" file="useradmin/register.xml" url="/register">
        <flowlink srcexit="home" destid="HOME"/>
    </element>
<element id="FORGOT_PASSWORD" file="useradmin/forgot_password.xml" url="/forgot_password">
        <flowlink srcexit="home" destid="HOME"/>
    </element>
</site>

roleareachooser.xml
------------------------------------------------------------
<element implementation="uk.co.communitytech.RoleAreaChooser">
    <submission name="role_area_chooser">
        <param name="role_area"/>
    </submission>
</element>

auth.xml
-------------------------------------------------------------
<element extends="rife/authenticated/database.xml">
<property name="datasource"><datasource>postgresql_live</datasource></property>
    <property name="template_name">login_box</property>
    <submission name="credentials">
        <param name="login"/>
        <param name="password"/>
    </submission>
    <childtrigger name="authid"/>
</element>

home.xml
---------------------------------------------------------------
<element implementation="uk.co.communitytech.Home">
</element>

credentials.xml
----------------------------------------------------------------
<element implementation="uk.co.communitytech.Credentials">
    <submission name="logout"/>
    <exit name="logout"/>
</element>

roleareachooser.html
----------------------------------------------------------------
<!--V 'role_area_info'/-->

<!--BV 'role_area_info'-->
<!--/BV-->

<!--B 'role_area_choices'-->
<p>You have more than one role/admin area combination available to you.<br/>Please
choose the one you want to use from the list below:</p>
<form name="role_area_chooser" action="[!V 'SUBMISSION:FORM:role_area_chooser'/]" method="post">
<!--V 'SUBMISSION:PARAMS:role_area_chooser'/-->
<!--V 'FORM:SELECT:role_area'/-->
<input type="submit" value="Choose">
</form>
<!--/B-->

<!--B 'unique_role_area'-->
Current role : <!--V 'role_name'/--> for <!--V 'admin_area_name'/-->
<!--/B-->


home.html
-----------------------------------------------------------------
<!--I 'header'/-->
<h2>Welcome</h2>
<p>Your login username will normally be your email address for access
to reports.<br/>If you don't yet have an account you can
<a href="[!V 'EXIT:QUERY:register'/]">register</a> for one.
</p>
<!--V 'ELEMENT:.LOGIN_BOX'/-->
<p><a href="[!V 'EXIT:QUERY:forgot_password'/]">I've forgotten my password!</a></p>
<!--V 'ELEMENT:.ROLE_AREA_CHOOSER'/-->
<!--I 'footer'/-->


_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users

Reply via email to