Skip to content

Using the logged user's ID

Agustín Borrego edited this page Dec 6, 2022 · 1 revision

There exists a special parameter, $loggedId, that can be used in any SQL query. When the query is executed, this parameter is replaced by the value of the primary key of the user that has accessed the endpoint. This information is obtained from the session token provided by the user, if no token is sent, then $loggedId is NULL.

For example, an endpoint that returns the user data of the logged in user can be defined as:

"loggedId": {
      "route": "/employees/profile",
      "method": "GET",
      "sql": "SELECT * FROM Employees WHERE employeeId = $loggedId",
      "auth_required": true
  }