-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding missing dbauth.xql and setting version to 1.7
- Loading branch information
Showing
2 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<package xmlns="http://expath.org/ns/pkg" name="http://gawati.org/client-data" abbrev="gawati-client-data" version="1.6" spec="1.0"> | ||
<package xmlns="http://expath.org/ns/pkg" name="http://gawati.org/client-data" abbrev="gawati-client-data" version="1.7" spec="1.0"> | ||
<title>Client Data</title> | ||
<dependency package="http://exist-db.org/apps/shared"/> | ||
</package> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module namespace dbauth="http://gawati.org/1.0/client/dbauth"; | ||
|
||
declare namespace xmldb="http://exist-db.org/xquery/xmldb"; | ||
import module namespace config="http://gawati.org/client-data/config" at "./config.xqm"; | ||
|
||
(: | ||
: This module provides 2 functions to enable writing to the database. Default | ||
: eXist-db execution context is "guest", cannot write to the db using "guest". | ||
: call dbauth:login() before calling a statement that writes a document to the db. | ||
: after that call dbauth:logout() to change execution context back to guest | ||
: | ||
:) | ||
|
||
|
||
|
||
(: | ||
: Logs in to the writable collection as specified in config:storage-info() | ||
: | ||
:) | ||
declare function dbauth:login() { | ||
let $s-map := config:storage-info() | ||
return dbauth:login($s-map) | ||
}; | ||
|
||
(: | ||
: Logs in to the writable collection as specified in the passed storage map | ||
: | ||
:) | ||
declare function dbauth:login($s-map) { | ||
let $log-in := xmldb:login($s-map("db-path"), $s-map("user"), $s-map("pw")) | ||
return $log-in | ||
}; | ||
|
||
|
||
declare function dbauth:logout() { | ||
let $s-map := config:storage-info() | ||
let $logout := dbauth:logout($s-map) | ||
return $logout | ||
}; | ||
|
||
declare function dbauth:logout($s-map) { | ||
let $log-in := xmldb:login($s-map("db-path"), "guest", "guest") | ||
let $logout:=session:invalidate() | ||
return $logout | ||
}; |