change namespace prefix xmldb: into xdb:

svn path=/trunk/eXist-1.0/; revision=215

xquery version "1.0";

declare namespace request="http://exist-db.org/xquery/request";
declare namespace xdb="http://exist-db.org/xquery/xmldb";

declare variable $database-uri as xs:string { "xmldb:exist:///db" };
declare variable $redirect-uri as xs:anyURI { xs:anyURI("session.xql") };

declare function local:login($user as xs:string) as element()?
{
    let $pass := request:request-parameter("pass", ""),
        $login := xdb:authenticate($database-uri, $user, $pass)
    return
        if ($login) then (
            request:set-session-attribute("user", $user),
            request:set-session-attribute("password", $pass),
            request:redirect-to(request:encode-url($redirect-uri))
        ) else

Login failed! Please retry.

};

declare function local:do-login() as element()?
{
    let $user := request:request-parameter("user", ())
    return
        if ($user) then
            local:login($user)
        else ()
};

request:create-session(),

        <title>Login</title>
        <link rel="stylesheet" type="text/css" href="login.css"/>

This is a protected resource. Only registered database users can log
        in. If you have not set up any users, login as "admin" and leave the
        password field empty. For testing purposes, you may also log in as
        "guest" with password "guest".

        <form action="{request:encode-url(request:request-uri())}">

                    Please Login

                    Username:
                    <input name="user" type="text" size="20"/>

                    Password:
                    <input name="pass" type="password" size="20"/>

                    <input type="submit"/>

        </form>

        { local:do-login() }

xquery version "1.0";

declare namespace request="http://exist-db.org/xquery/request";
declare namespace xmldb="http://exist-db.org/xquery/xmldb";

declare variable $database-uri as xs:string { "xmldb:exist:///db" };
declare variable $redirect-uri as xs:anyURI { xs:anyURI("session.xql") };

declare function local:login($user as xs:string) as element()?
{
    let $pass := request:request-parameter("pass", ""),
        $login := xmldb:authenticate($database-uri, $user, $pass)
    return
        if ($login) then (
            request:set-session-attribute("user", $user),
            request:set-session-attribute("password", $pass),
            request:redirect-to(request:encode-url($redirect-uri))
        ) else

Login failed! Please retry.

};

declare function local:do-login() as element()?
{
    let $user := request:request-parameter("user", ())
    return
        if ($user) then
            local:login($user)
        else ()
};

request:create-session(),

        <title>Login</title>
        <link rel="stylesheet" type="text/css" href="login.css"/>

This is a protected resource. Only registered database users can log
        in. If you have not set up any users, login as "admin" and leave the
        password field empty. For testing purposes, you may also log in as
        "guest" with password "guest".

        <form action="{request:encode-url(request:request-uri())}">

                    Please Login

                    Username:
                    <input name="user" type="text" size="20"/>

                    Password:
                    <input name="pass" type="password" size="20"/>

                    <input type="submit"/>

        </form>

        { local:do-login() }