Skip to content

User Roles API

CodingMarco edited this page May 11, 2021 · 1 revision

Introduction

  • A user can be assigned roles which grant certain permissions to that user
  • A user can also have no roles
  • There are currently only two roles implemented in this Projekt: "Webmaster" and "Vorstand", because more are not needed
  • Role names are case sensitive
  • Only the webmaster can change the roles of a user and see the roles of all users as part of the Get user info API call
  • The first user created is automatically assigned the "Webmaster" role

API

Set the roles of a user

  • Sets the roles of a user to the specified roles.
  • "Webmaster" role required
  • There is no "add role" or "remove role", you just overwrite the roles of a user.

PUT: /api/users/user_roles

Json Parameters:

  • user_id: The id of the target user
  • roles: Array of role names that should be assigned to the user. Roles can only be "Webmaster" or "Vorstand". To remove all roles, send an empty array.

Return value:

  • success: true when successful, otherwise false. In the second case, an error object is returned as described here.

Get the roles of a user

  • Gets the roles of a user.
  • "Webmaster" role required

GET: /api/users/user_roles

Json Parameters:

  • user_id: The id of the target user

Return value:

  • roles: An array containing the role names assigned to the user. Empty array if the user has no roles.
  • success: true when successful, otherwise false. In the second case, an error object is returned as described here.
Clone this wiki locally