XQuery/URL 驅動授權
外觀
< XQuery
您想在頁面渲染之前檢查使用者是否已登入。
此示例將使用自定義控制器.xql 檔案來實現這一點。
示例控制器.xql 檔案
(: Protected resource: user is required to log in with valid credentials.
If the login fails or no credentials were provided, the request is
redirected
to the login.xml page. :)
else if ($exist:resource eq 'protected.xml') then
let $login := local:set-user()
return
if ($login) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
{$login}
<view>
<forward url="style.xql"/>
</view>
</dispatch>
else
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="login.xml"/>
<view>
<forward url="style.xql"/>
</view>
</dispatch>
else
(: everything else is passed through :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="yes"/>
</dispatch>