added handler for return key -> submits form

parent 9b7a2b74
This diff is collapsed.
......@@ -39,7 +39,7 @@
<exec executable="polymer">
<arg value="build"/>
<arg value="--shell"/>
<arg value="index.html"/>
<arg value="restricted.html"/>
</exec>
</target>
......
......@@ -23,33 +23,43 @@ else if ($exist:path = "/") then(
)
(: auth:isPathAllowed([path],[group]) :)
else if (ends-with($exist:path, "index.html")) then (
else if (ends-with($exist:path, "restricted.html")) then (
login:set-user("org.exist.login", (), true()),
let $userParam := request:get-parameter("user","")
let $user := request:get-attribute("org.exist.login.user")
let $out := request:get-parameter("logout",())
let $result := if (not($userParam != data($user))) then "true" else "false"
(:
let $log := util:log("info","user: <" || data($user) || ">")
let $log := util:log("info","userParam: <" || $userParam || ">")
let $result := if (not($userParam != data($user))) then "true" else "false"
let $log := util:log("info", $result)
:)
return
if($out = "true") then(
console:log("logout: dispatch"),
(:
When there is a logout request parameter we send the user back to the unrestricted page.
:)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="index.html"/>
</dispatch>
)
else if ($user and sm:is-dba($user)) then
(:
successful login. The user has authenticated and is in the 'dba' group.
:)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="no"/>
</dispatch>
(:
if a user was send as request param
and it is NOT the same as the $user
a former login attempt has failed.
:)
else if(not(string($userParam) eq string($user))) then
(:
if a user was send as request param 'user'
AND it is NOT the same as the $user
a former login attempt has failed.
Here a duplicate of the login.html is used. This is certainly not the most elegant solution. Just here
to not complicate things further with templating etc.
:)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="fail.html"/>
</dispatch>
......
......@@ -80,7 +80,7 @@
*
* @customElement
* @polymer
* @demo demo/index.html
* @demo demo/restricted.html
*/
class ExistdbLogin extends Polymer.Element {
......
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://expath.org/ns/pkg" name="http://exist-db.org/apps/existdb-login" abbrev="existdb-login" version="0.7.0" spec="1.0">
<package xmlns="http://expath.org/ns/pkg" name="http://exist-db.org/apps/existdb-login" abbrev="existdb-login" version="0.8.0" spec="1.0">
<title>existdb-login</title>
</package>
\ No newline at end of file
......@@ -9,7 +9,28 @@
</head>
<body>
<existdb-login target="index.html" failed="true" style="width:400px; height: 200px;">&#160;</existdb-login>
<h2>existdb-login Web Component</h2>
<p>
This page is nearly a copy of the login.html. It just provides an additional attribute to the existdb-login component
to show an error.
</p>
<existdb-login target="restricted.html" failed="true" style="width:400px; height: 200px;">&#160;</existdb-login>
<h2>native form login</h2>
<div>
<form class="form" id="form" action="restricted.html" method="post">
<input type="hidden" name="origin" value="{$origin}" autocomplete="on"/>
<input label="User ID" id="user" name="user" autofocus="autofocus" required="required"
error="Please input your username"/>
<input label="Password" type="password" id="password" name="password"
error="Please input your password"/>
<button type="submit" on-click="_handleSubmit">Sign me in</button>
</form>
</div>
</body>
</html>
......@@ -7,10 +7,10 @@
<body>
<h1>eXistdb login Demo</h1>
<h2 style="color:red;">This page should not be shown unless authenticated as admin.</h2>
<h2 style="color:green;">This page is for the public (no login required).</h2>
<a href="index.html?logout=true">logout here</a>
<a href="restricted.html">login</a>
</body>
</html>
......@@ -9,10 +9,18 @@
</head>
<body>
<existdb-login target="index.html" style="width:400px; height: 200px;">&#160;</existdb-login>
<h2>existdb-login Web Component</h2>
<!--
<form class="form" id="form" action="index.html" method="post">
<p>
Both forms can be used to login. Use the native one if you don't want to deal with Web Components.
</p>
<existdb-login target="restricted.html" style="width:400px; height: 200px;">&#160;</existdb-login>
<h2>native form login</h2>
<div>
<form class="form" id="form" action="restricted.html" method="post">
<input type="hidden" name="origin" value="{$origin}" autocomplete="on"/>
<input label="User ID" id="user" name="user" autofocus="autofocus" required="required"
error="Please input your username"/>
......@@ -20,8 +28,7 @@
error="Please input your password"/>
<button type="submit" on-click="_handleSubmit">Sign me in</button>
</form>
-->
</div>
</body>
</html>
<html>
<head>
<meta charset="utf-8"/>
<title>existdb-login</title>
</head>
<body>
<h1>eXistdb login Demo</h1>
<h2 style="color:red;">This page should not be shown unless authenticated as admin.</h2>
<a href="restricted.html?logout=true">logout here</a>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment