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>