(NEEDS REWRITE) JavaScript API Reference

Usage: If you want to use the API, you have to include the Resources/public/js/api.js script.

Dependencies: jQuery, FOSJsRouting

The response from the server is always a JSON object and it always has a result property, that is "OK" (success) or "ERR" (failure). On failure, a message property is also present.

The authentication is done with sessions, and the user must have ROLE_ADMIN role assigned.


jqXHR Loginet.Platform.UserAdmin.addUser (username, email, password)

Creates a new user in the database with the given parameters.

Parameters

Parameter name Type Notes
username String
email String Must be a valid e-mail address.
password String

Server responses

Response message Description
OK User added successfully.
BAD_PARAMS Some parameters are invalid or missing.
USERNAME_OCCUPIED There is another user with that username.

jqXHR Loginet.Platform.UserAdmin.removeUser (id)

Removed the given user from the database permanently.

Parameters

Parameter name Type Notes
id integer The ID of the user.

Server responses

Response message Description
OK User removed successfully.
BAD_PARAMS Some parameters are invalid or missing.
NOT_FOUND The user with the specified ID is not found.
SELF_REMOVAL Self removal is forbidden.

jqXHR Loginet.Platform.UserAdmin.modifyUser (id, username, email, password)

Modifies the users's username, e-mail or password. The given parameters will replace the current values (except for the password) in the database.

Parameters

Parameter name Type Notes
id integer The ID of the user.
username String
email String Must be a valid e-mail address.
password String Leave it empty to not change the password.

Server responses

Response message Description
OK User modified successfully.
BAD_PARAMS Some parameters are invalid or missing.
NOT_FOUND The user with the specified ID is not found.
USERNAME_OCCUPIED There is another user with that username.