Changes

Jump to navigation Jump to search
1,840 bytes added ,  17:53, 21 November 2017
no edit summary
=Conventions=
All functions and errors in this module and errors are assigned to the <code><nowiki>http://basex.org/modules/user</nowiki></code> namespace, which is statically bound to the {{Code|user}} prefix.<br/>
=Read Operations=
==user:list==
 
{{Mark|Updated with Version 8.5}}: If called by non-admins, will only return the current user.
{| width='100%'
|-
| '''Summary'''
|Returns the names of all registered usersthat are visible to the current user.
|-
| '''Examples'''
==user:list-details==
 
{{Mark|Updated with Version 8.5}}: If called by non-admins, will only return the current user.
{| width='100%'
|-
| '''Summary'''
|Returns an element sequence, containing all registered users and their permissionsthat are visible to the current user.<br/>In addition to the [[Commands#SHOW_USERS|SHOW USERS]] command, encoded password strings and database permissions will be output. A user {{Code|$name}} can be specified to filter the results in advance.
|-
| '''Examples'''
| '''Errors'''
|{{Error|name|#Errors}} The specified user name is invalid.
|}
 
==user:check==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|user:check|$name as xs:string, $password as xs:string|xs:empty-sequence()}}<br/>
|-
| '''Summary'''
|Checks if the specified user and password is correct. Raises errors otherwise.
|-
| '''Examples'''
|
* {{Code|user:check('admin', 'admin')}} will raise an error if the admin password was changed.
|-
| '''Errors'''
|{{Error|name|#Errors}} The specified user name is invalid.<br/>{{Error|unknown|#Errors}} The specified user does not exist.<br/>{{Error|password|#Errors}} The specified password is wrong.<br/>
|}
 
==user:info==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|user:info||element(info)}}
|-
| '''Summary'''
|Returns an <code>info</code> element, which can be used to organize application-specific data. By default, the element has no contents. It can be modified via [[#user:update-info|user:update-info]].
|-
| '''Examples'''
|
* After a fresh installation, {{Code|user:info()}} returns <code><info/></code>.
|}
| '''Errors'''
|{{Error|unknown|#Errors}} The specified user name is unknown.<br/>{{Error|name|#Errors}} The specified user name is invalid.<br/>{{Error|update|#Errors}} The operation can only be performed once per user or database pattern.
|}
 
==user:update-info==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|user:update-info|$info as element(info)|empty-sequence()}}
|-
| '''Summary'''
|Updates the <code>info</code> element with {{Code|$info}}. This node can be used to organize application-specific data (groups, enhanced user info, etc.).
|-
| '''Examples'''
|
* Store initial groups information:
<pre class="brush:xquery">
user:update-info(element info {
for $group in ('editor', 'author', 'writer')
return element group { $group }
})
</pre>
* Assign a group to a new user:
<pre class="brush:xquery">
let $user := 'john', $pw := '8hKJ@%.c/!0O', $group := 'editor'
return (
user:create($user, $pw),
user:update-info(user:info() update
insert node <user name='{ $user }' group='{ $group }'/> into .
)
)
</pre>
|}
! width="110"|Code
|Description
|-
|{{Code|admin}}
|The "admin" user cannot be modified.
|-
|{{Code|conflict}}
|A user cannot be both altered and dropped.
|-
|{{Code|equal}}
|Name of old and new user is equal.
|-
|{{Code|local}}
|A local permission can only be 'none', 'read' or 'write'.
|-
|{{Code|logged-in}}
|The specified user is currently logged in.
|-
|{{Code|name}}
|The specified user name is invalid.
|-
|{{Code|password}}
|The specified password is wrong.
|-
|{{Code|pattern}}
|{{Code|unknown}}
|The specified user does not exist.
|-
|{{Code|admin}}
|The "admin" user cannot be modified.
|-
|{{Code|equal}}
|Name of old and new user is equal.
|-
|{{Code|local}}
|A local permission can only be 'none', 'read' or 'write'.
|-
|{{Code|logged-in}}
|The specified user is currently logged in.
|-
|{{Code|update}}
|The operation can only be performed once per user or database pattern.
|-
|{{Code|conflict}}
|A user cannot be both altered and dropped.
|}
;Version 8.6
* Added: [[#user:check|user:check]], [[#user:info|user:info]], [[#user:update-info|user:update-info]].
* Updated: [[#user:list|user:list]], [[#user:list-details|user:list-details]]: If called by non-admins, will only return the current user.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu