Mercurial > hg > mpdl-group
diff software/eXist/webapp/mpdl/doc/login-exist.xql @ 7:5589d865af7a
Erstellung XQL/XSL Applikation
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Feb 2011 15:16:46 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/login-exist.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,61 @@ +xquery version "1.0"; + +import module namespace functx = "http://www.functx.com" at "../util/functx.xql"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace response="http://exist-db.org/xquery/response"; +declare namespace session="http://exist-db.org/xquery/session"; + +declare variable $docOperationExistUrlStr { "http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/doc/doc-operation-exist.xql"}; +declare variable $redirect-uri as xs:anyURI { xs:anyURI($docOperationExistUrlStr) }; + +declare function local:login($userName as xs:string, $password as xs:string) { + let $eSciDocCookieId := mpdldoc:escidoc-login($userName, $password) + return + if ($eSciDocCookieId = '' or empty($eSciDocCookieId)) + then + <p style="color:red">Login failed: User/password is not correct.</p> + else if ($eSciDocCookieId = '-10') + then + <p style="color:red">Login failed: Your user account has not enough user rights for the MPDL document management. Please send an e-mail to <a href="mailto:jwillenborg@mpiwg-berlin.mpg.de">Josef Willenborg</a> with subject "MPDL document interface: get user rights"</p> + else + ( + session:set-attribute("userName", $userName), + session:set-attribute("eSciDocCookieId", $eSciDocCookieId), + response:redirect-to(session:encode-url($redirect-uri)) + ) +}; + +declare function local:do-login() { + let $userName := request:get-parameter("userName", "") + let $password := request:get-parameter("password", "") + return + if ($userName = '') then + '' + else + local:login($userName, $password) +}; + +session:invalidate(), +session:create(), + +let $title := "MPDL: eXist document management" +return +<html> +<head> +<title>{$title}</title> +</head> +<body> + <h1>{$title}</h1> + <form action="{session:encode-url(request:get-uri())}"> + <table class="login"> + <b>User name: </b><input type="text" size="20" name="userName"/><p/> + <b>Password: </b><input type="password" size="20" name="password"/><p/> + <input type="submit" value="Login"/> + </table> + </form> + { local:do-login() } + <hr/> + See the <a href="login-exist.xql?_source=yes">XQuery source</a> of this page, if you find a bug <a href="https://itgroup.mpiwg-berlin.mpg.de:8080/tracs/mpdl-project-software/newticket">let us know</a> +</body> +</html> \ No newline at end of file