comparison 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
comparison
equal deleted inserted replaced
6:2396a569e446 7:5589d865af7a
1 xquery version "1.0";
2
3 import module namespace functx = "http://www.functx.com" at "../util/functx.xql";
4
5 declare namespace request="http://exist-db.org/xquery/request";
6 declare namespace response="http://exist-db.org/xquery/response";
7 declare namespace session="http://exist-db.org/xquery/session";
8
9 declare variable $docOperationExistUrlStr { "http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/doc/doc-operation-exist.xql"};
10 declare variable $redirect-uri as xs:anyURI { xs:anyURI($docOperationExistUrlStr) };
11
12 declare function local:login($userName as xs:string, $password as xs:string) {
13 let $eSciDocCookieId := mpdldoc:escidoc-login($userName, $password)
14 return
15 if ($eSciDocCookieId = '' or empty($eSciDocCookieId))
16 then
17 <p style="color:red">Login failed: User/password is not correct.</p>
18 else if ($eSciDocCookieId = '-10')
19 then
20 <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 &quot;MPDL document interface: get user rights&quot;</p>
21 else
22 (
23 session:set-attribute("userName", $userName),
24 session:set-attribute("eSciDocCookieId", $eSciDocCookieId),
25 response:redirect-to(session:encode-url($redirect-uri))
26 )
27 };
28
29 declare function local:do-login() {
30 let $userName := request:get-parameter("userName", "")
31 let $password := request:get-parameter("password", "")
32 return
33 if ($userName = '') then
34 ''
35 else
36 local:login($userName, $password)
37 };
38
39 session:invalidate(),
40 session:create(),
41
42 let $title := "MPDL: eXist document management"
43 return
44 <html>
45 <head>
46 <title>{$title}</title>
47 </head>
48 <body>
49 <h1>{$title}</h1>
50 <form action="{session:encode-url(request:get-uri())}">
51 <table class="login">
52 <b>User name: </b><input type="text" size="20" name="userName"/><p/>
53 <b>Password: </b><input type="password" size="20" name="password"/><p/>
54 <input type="submit" value="Login"/>
55 </table>
56 </form>
57 { local:do-login() }
58 <hr/>
59 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>
60 </body>
61 </html>