Skip to content

Commit

Permalink
small optmisiations
Browse files Browse the repository at this point in the history
  • Loading branch information
line-o committed Feb 20, 2023
1 parent 6d563d5 commit 4eeb7da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
35 changes: 16 additions & 19 deletions controller.xq
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if ($exist:path eq '') then
<redirect url="{$local:uri}/"/>
</dispatch>

else if ($exist:path eq '/' and $user-allowed) then
else if ($exist:path eq '/') then
let $path :=
if (
lower-case($local:uri) = "/exist/apps/exide/" and
Expand Down Expand Up @@ -105,23 +105,6 @@ else if ($local:method = 'get' and $exist:resource = "backdrop.svg") then
</forward>
</dispatch>

(:
: Login a user via AJAX. Just returns a 401 if login fails.
:)
else if (
$local:wants-json and
$local:method = ('post') and
$exist:resource = 'login' and
$user-allowed
)
then (
util:declare-option("output:method", "json"),
<status>
<user>{$user}</user>
<isAdmin json:literal="true">{$user-is-dba}</isAdmin>
</status>
)

(: handle unauthorized request :)

else if (not($user-allowed))
Expand All @@ -141,7 +124,21 @@ then (
)

(: restricted resources :)

(:
: Login a user via AJAX. Just returns a 401 if login fails.
:)
else if (
$local:wants-json and
$local:method = 'post' and
$exist:resource = 'login'
)
then (
util:declare-option("output:method", "json"),
<status>
<user>{$user}</user>
<isAdmin json:literal="true">{$user-is-dba}</isAdmin>
</status>
)
else if ($local:method = ('get', 'post') and $exist:resource = ('login.html', 'login'))
then (
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
Expand Down
1 change: 0 additions & 1 deletion login.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
<h1 class="header">Sign in</h1>
<form action="login" method="post">
<input type="hidden" name="duration" value="P7D"/>
<input id="route" type="hidden" name="route"/>
<div class="form-group">
<label for="user">Username</label>
<input id="user" name="user" class="form-control"
Expand Down

0 comments on commit 4eeb7da

Please sign in to comment.