3XX - User management

300 - User authentication

Tries to authenticate the provided data.user with the data.password into the system. If the user/password combination is correct, returns an "OK" data.status ("KO" if not) and the data.user, data.displayName and data.roles of the logged user. The server will save the logged user into the connection session, so the next codes that requires authentication will work without providing user or token.

In

{"type":300,"data":{"user":"user","password":"password"}}

Out

{"type":300,"data":{"status":"OK","user":"user","displayName":"user","roles":["admin"]}}

301 - User registration

Tries to register an user with the provided data.user, data.password and data.email. If the insertion is correct, returns an "OK" as data.status. If the same user exists, or the data doesn't meet the requirements (username or password length), an "KO" data.status is returned. The first registered user will gain administrator privileges by default.

In

//

Out

//

302 - User data edit

Updates the user data. Only data.displayName, data.password and data.email could be changed. Only a user can update its data by being authenticated and providing data.password. An administrator can change the data of any user without providing the data.password. Requieres authentication or administration privileges.

In

//

Out

//

310 - Users list

Returns the users list filtered by name (data.filter), you can left it as empty string if you don't want to filter. The results are paginated, so a number page (data.page) and a number of elements per page (data.pageSize) should be specified. Requieres authentication.

In

{"type":310,"data":{"pageSize":10,"page":1,"filter":""}}

Out

{"type":310,"data":{"pages":1,"users":[{"user":"user","displayName":"user","email":"user@mail.com","roles":["admin"]},{"user":"user2","displayName":"user2","email":"user2@mail.com","roles":[]}]}}

320 - Roles list

Returns the roles list.

In

{"type":320}

Out

{"type":320,"data":{"roles":[{"name":"admin","description":"Highest permission on the system"}]}}

321 - Role creation

Creates a new role with the provided data.name and data.description. If data.remove is provided and set to true, removes it. Requires administration privileges.

In

{"type":321,"data":{"name":"new-role","description":"New role"}}

Out

{"type":321,"data":{"status":"OK"}}

322 - Role assignation

Adds the role (data.name) to a user (data.user). Requires administration privileges.

In

{"type":322,"data":{"name":"new-role","user":"user"}}

Out

{"type":322,"data":{"status":"OK"}}

330 - Groups list

Returns the groups list filtered by name (data.filter), you can left it as empty string if you don't want to filter. The results are paginated, so a number page (data.page) and a number of elements per page (data.pageSize) should be specified. Requires authentication.

In

{"type":330,"data":{"filter":"","pageSize":10,"page":1}}

Out

{"type":330,"data":{"pages":1,"groups":[{"key":"best guild","name":"Best Guild","description":"Just the best","owner":"user","members":["user"]}]}}

331 - Group creation

Creates a group with the provided data.name and data.description. The user who sends this command will be added to the group as owner and as member. If a group with the same name exists and the command is sent by the owner or an admin, it will be edited to allow description changes. Requires authentication.

In

{"type":331,"data":{"name":"Best Guild","description":"Just the best"}}

Out

{"type":331,"data":{"status":"OK"}}

332 - Group assignation

Add a data.user to a data.group. Only the owner of the group is allowed to do it. Requires authentication.

In

{"type":332,"data":{"group":"best guild","user":"user2"}}

Out

{"type":332,"data":{"status":"OK"}}

333 - User groups

Returns the list of groups that the data.user is member. Requires authentication.

In

{"type":333,"data":{"user":"user"}}

Out

{"type":333,"data":{"user":"user","displayName":"pepe","groups":["Best Guild"]}}

340 - Public key/value storage query

Queries the provided data.key from the public key/value storage (anyone can read from it).

In

{"type":340,"data":{"key":"key"}}

Out

{"type":340,"data":{"key":"key","value":"value"}}

341 - Public key/value storage upsert

Makes an upsert (insert or update) into the public key/value storage (anyone can upsert).

In

{"type":341,"data":{"key":"key","value":"value"}}

Out

{"type":341,"data":{"status":"OK"}}

Last updated