mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Add wildcard support to management.js.
This commit is contained in:
parent
ef6cff1d24
commit
9f2df6af2a
2 changed files with 33 additions and 19 deletions
|
@ -44,7 +44,7 @@ document.getElementById('passwordform').onsubmit = async function(e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await setPassword(group, user, new1, old);
|
await setPassword(group, user, false, new1, old);
|
||||||
document.getElementById('old').value = '';
|
document.getElementById('old').value = '';
|
||||||
document.getElementById('new1').value = '';
|
document.getElementById('new1').value = '';
|
||||||
document.getElementById('new2').value = '';
|
document.getElementById('new2').value = '';
|
||||||
|
|
|
@ -216,17 +216,33 @@ async function listUsers(group) {
|
||||||
return await listObjects(`/galene-api/v0/.groups/${group}/.users/`);
|
return await listObjects(`/galene-api/v0/.groups/${group}/.users/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* userURL returns the URL for a user entry
|
||||||
|
*
|
||||||
|
* @param {string} group
|
||||||
|
* @param {string} user
|
||||||
|
* @param {boolean} wildcard
|
||||||
|
*/
|
||||||
|
function userURL(group, user, wildcard) {
|
||||||
|
if(wildcard)
|
||||||
|
return `/galene-api/v0/.groups/${group}/.wildcard-user`;
|
||||||
|
else if(user === "")
|
||||||
|
return `/galene-api/v0/.groups/${group}/.empty-user`;
|
||||||
|
else
|
||||||
|
return `/galene-api/v0/.groups/${group}/.users/${user}`
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUser returns a given user entry.
|
* getUser returns a given user entry.
|
||||||
*
|
*
|
||||||
* @param {string} group
|
* @param {string} group
|
||||||
* @param {string} user
|
* @param {string} user
|
||||||
|
* @param {boolean} wildcard
|
||||||
* @param {string} [etag]
|
* @param {string} [etag]
|
||||||
* @returns {Promise<Object>}
|
* @returns {Promise<Object>}
|
||||||
*/
|
*/
|
||||||
async function getUser(group, user, etag) {
|
async function getUser(group, user, wildcard, etag) {
|
||||||
return await getObject(`/galene-api/v0/.groups/${group}/.users/${user}`,
|
return await getObject(userURL(group, user, wildcard), etag);
|
||||||
etag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,11 +251,11 @@ async function getUser(group, user, etag) {
|
||||||
*
|
*
|
||||||
* @param {string} group
|
* @param {string} group
|
||||||
* @param {string} user
|
* @param {string} user
|
||||||
|
* @param {boolean} wildcard
|
||||||
* @param {Object} values
|
* @param {Object} values
|
||||||
*/
|
*/
|
||||||
async function createUser(group, user, values) {
|
async function createUser(group, user, wildcard, values) {
|
||||||
return await createObject(`/galene-api/v0/.groups/${group}/.users/${user}`,
|
return await createObject(userURL(group, user, wildcard), values);
|
||||||
values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,12 +263,11 @@ async function createUser(group, user, values) {
|
||||||
*
|
*
|
||||||
* @param {string} group
|
* @param {string} group
|
||||||
* @param {string} user
|
* @param {string} user
|
||||||
|
* @param {boolean} wildcard
|
||||||
* @param {string} [etag]
|
* @param {string} [etag]
|
||||||
*/
|
*/
|
||||||
async function deleteUser(group, user, etag) {
|
async function deleteUser(group, user, wildcard, etag) {
|
||||||
return await deleteObject(
|
return await deleteObject(userURL(group, user, wildcard), etag);
|
||||||
`/galene-api/v0/.groups/${group}/.users/${user}/`, etag,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,11 +276,11 @@ async function deleteUser(group, user, etag) {
|
||||||
* @param {string} group
|
* @param {string} group
|
||||||
* @param {string} user
|
* @param {string} user
|
||||||
* @param {Object} values
|
* @param {Object} values
|
||||||
|
* @param {boolean} wildcard
|
||||||
* @param {string} [etag]
|
* @param {string} [etag]
|
||||||
*/
|
*/
|
||||||
async function updateUser(group, user, values, etag) {
|
async function updateUser(group, user, wildcard, values, etag) {
|
||||||
return await updateObject(`/galene-api/v0/.groups/${group}/.users/${user}`,
|
return await updateObject(userURL(group, user, wildcard), values, etag);
|
||||||
values, etag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,10 +290,11 @@ async function updateUser(group, user, values, etag) {
|
||||||
*
|
*
|
||||||
* @param {string} group
|
* @param {string} group
|
||||||
* @param {string} user
|
* @param {string} user
|
||||||
|
* @param {boolean} wildcard
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @param {string} [oldpassword]
|
* @param {string} [oldpassword]
|
||||||
*/
|
*/
|
||||||
async function setPassword(group, user, password, oldpassword) {
|
async function setPassword(group, user, wildcard, password, oldpassword) {
|
||||||
let options = {
|
let options = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -292,15 +308,13 @@ async function setPassword(group, user, password, oldpassword) {
|
||||||
`Basic ${btoa(user + ':' + oldpassword)}`
|
`Basic ${btoa(user + ':' + oldpassword)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
let r = await fetch(
|
let r = await fetch(userURL(group, user, wildcard) + '/.password', options);
|
||||||
`/galene-api/v0/.groups/${group}/.users/${user}/.password`,
|
|
||||||
options);
|
|
||||||
if(!r.ok)
|
if(!r.ok)
|
||||||
throw httpError(r);
|
throw httpError(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* listUsers lists the tokens for a given group.
|
* listTokens lists the tokens for a given group.
|
||||||
*
|
*
|
||||||
* @param {string} group
|
* @param {string} group
|
||||||
* @returns {Promise<Array<string>>}
|
* @returns {Promise<Array<string>>}
|
||||||
|
|
Loading…
Reference in a new issue