Compare commits
2
Commits
c5fede30ad
...
5beb64c1e6
@@ -22,9 +22,7 @@ class AuthController : public drogon::HttpController<AuthController>
|
|||||||
"/api/v1/auth/change-password",
|
"/api/v1/auth/change-password",
|
||||||
drogon::Post);
|
drogon::Post);
|
||||||
ADD_METHOD_TO(AuthController::me, "/api/v1/me", drogon::Get);
|
ADD_METHOD_TO(AuthController::me, "/api/v1/me", drogon::Get);
|
||||||
ADD_METHOD_TO(AuthController::editUser,
|
ADD_METHOD_TO(AuthController::editUser, "/api/v1/me", drogon::Patch);
|
||||||
"/api/v1/me",
|
|
||||||
drogon::Patch);
|
|
||||||
METHOD_LIST_END
|
METHOD_LIST_END
|
||||||
|
|
||||||
void registerCitizen(
|
void registerCitizen(
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ Base path: `/api/v1`.
|
|||||||
- `POST /auth/login/password`: password login fallback.
|
- `POST /auth/login/password`: password login fallback.
|
||||||
- `POST /auth/change-password`: change the authenticated user's password.
|
- `POST /auth/change-password`: change the authenticated user's password.
|
||||||
- `GET /me`: return the authenticated user.
|
- `GET /me`: return the authenticated user.
|
||||||
|
- `PATCH /me`: edit user informations.
|
||||||
|
|
||||||
Protected endpoints use:
|
Protected endpoints use:
|
||||||
|
|
||||||
|
|||||||
@@ -385,6 +385,21 @@
|
|||||||
],
|
],
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"EditUserRequest": {
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {
|
||||||
|
"first_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"last_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"phone": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"EmailRequest": {
|
"EmailRequest": {
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -1597,7 +1612,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Lists configured municipal areas.",
|
"description": "Lists configured municipal areas.",
|
||||||
"operationId": "AdminController.listAreas",
|
"operationId": "AdminController.listAreas",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -1615,7 +1630,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "List areas",
|
"summary": "List areas",
|
||||||
@@ -1626,7 +1641,7 @@
|
|||||||
"post": {
|
"post": {
|
||||||
"description": "Creates a municipal area with GeoJSON boundary.",
|
"description": "Creates a municipal area with GeoJSON boundary.",
|
||||||
"operationId": "AdminController.createArea",
|
"operationId": "AdminController.createArea",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -1660,7 +1675,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Create area",
|
"summary": "Create area",
|
||||||
@@ -1673,7 +1688,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Lists active report categories.",
|
"description": "Lists active report categories.",
|
||||||
"operationId": "AdminController.listCategories",
|
"operationId": "AdminController.listCategories",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -1691,7 +1706,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "List categories",
|
"summary": "List categories",
|
||||||
@@ -1702,7 +1717,7 @@
|
|||||||
"post": {
|
"post": {
|
||||||
"description": "Creates a report category.",
|
"description": "Creates a report category.",
|
||||||
"operationId": "AdminController.createCategory",
|
"operationId": "AdminController.createCategory",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -1736,7 +1751,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Create category",
|
"summary": "Create category",
|
||||||
@@ -1800,7 +1815,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "List moderation flags",
|
"summary": "List moderation flags",
|
||||||
@@ -1857,7 +1872,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Update moderation flag",
|
"summary": "Update moderation flag",
|
||||||
@@ -1870,7 +1885,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Returns report statistics for administration dashboards.",
|
"description": "Returns report statistics for administration dashboards.",
|
||||||
"operationId": "AdminController.overviewStats",
|
"operationId": "AdminController.overviewStats",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -1891,7 +1906,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Overview stats",
|
"summary": "Overview stats",
|
||||||
@@ -1904,7 +1919,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Lists intervention teams.",
|
"description": "Lists intervention teams.",
|
||||||
"operationId": "AdminController.listTeams",
|
"operationId": "AdminController.listTeams",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -1922,7 +1937,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "List teams",
|
"summary": "List teams",
|
||||||
@@ -1933,7 +1948,7 @@
|
|||||||
"post": {
|
"post": {
|
||||||
"description": "Creates an intervention team.",
|
"description": "Creates an intervention team.",
|
||||||
"operationId": "AdminController.createTeam",
|
"operationId": "AdminController.createTeam",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -1967,7 +1982,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Create team",
|
"summary": "Create team",
|
||||||
@@ -1980,7 +1995,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Lists platform users with role information.",
|
"description": "Lists platform users with role information.",
|
||||||
"operationId": "AdminController.listUsers",
|
"operationId": "AdminController.listUsers",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -2001,7 +2016,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "List users",
|
"summary": "List users",
|
||||||
@@ -2058,7 +2073,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Ban or unban user",
|
"summary": "Ban or unban user",
|
||||||
@@ -2115,7 +2130,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Update user roles",
|
"summary": "Update user roles",
|
||||||
@@ -2128,7 +2143,7 @@
|
|||||||
"post": {
|
"post": {
|
||||||
"description": "Changes the authenticated user's password.",
|
"description": "Changes the authenticated user's password.",
|
||||||
"operationId": "AuthController.changePassword",
|
"operationId": "AuthController.changePassword",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -2162,7 +2177,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Change password",
|
"summary": "Change password",
|
||||||
@@ -2175,7 +2190,7 @@
|
|||||||
"post": {
|
"post": {
|
||||||
"description": "Password-based login fallback for local development.",
|
"description": "Password-based login fallback for local development.",
|
||||||
"operationId": "AuthController.loginWithPassword",
|
"operationId": "AuthController.loginWithPassword",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -2211,7 +2226,7 @@
|
|||||||
"post": {
|
"post": {
|
||||||
"description": "Sends a one-time code by email through Mailpit locally.",
|
"description": "Sends a one-time code by email through Mailpit locally.",
|
||||||
"operationId": "AuthController.requestOtp",
|
"operationId": "AuthController.requestOtp",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -2247,7 +2262,7 @@
|
|||||||
"post": {
|
"post": {
|
||||||
"description": "Verifies an email OTP and creates an API token.",
|
"description": "Verifies an email OTP and creates an API token.",
|
||||||
"operationId": "AuthController.verifyOtp",
|
"operationId": "AuthController.verifyOtp",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -2283,7 +2298,7 @@
|
|||||||
"post": {
|
"post": {
|
||||||
"description": "Creates a citizen account with personal data and password.",
|
"description": "Creates a citizen account with personal data and password.",
|
||||||
"operationId": "AuthController.registerCitizen",
|
"operationId": "AuthController.registerCitizen",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -2319,7 +2334,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Serves a local Swagger UI page backed by openapi.json.",
|
"description": "Serves a local Swagger UI page backed by openapi.json.",
|
||||||
"operationId": "ApiController.docs",
|
"operationId": "ApiController.docs",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -2342,7 +2357,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Returns process health without checking dependencies.",
|
"description": "Returns process health without checking dependencies.",
|
||||||
"operationId": "ApiController.health",
|
"operationId": "ApiController.health",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -2365,7 +2380,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Returns the authenticated user's profile and permissions.",
|
"description": "Returns the authenticated user's profile and permissions.",
|
||||||
"operationId": "AuthController.me",
|
"operationId": "AuthController.me",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -2383,13 +2398,55 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Current user",
|
"summary": "Current user",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Auth"
|
"Auth"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"patch": {
|
||||||
|
"description": "Updates fields of the authenticated user's profile.",
|
||||||
|
"operationId": "AuthController.editUser",
|
||||||
|
"parameters": [ ],
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/EditUserRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/OkResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "User profile updated successfully."
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Invalid parameter type or structural error."
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"$ref": "#/components/responses/Unauthorized"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"bearerAuth": [ ]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"summary": "Edit current user profile",
|
||||||
|
"tags": [
|
||||||
|
"Auth"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/api/v1/me/rewards": {
|
"/api/v1/me/rewards": {
|
||||||
@@ -2434,7 +2491,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Reward ledger",
|
"summary": "Reward ledger",
|
||||||
@@ -2485,7 +2542,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "List notifications",
|
"summary": "List notifications",
|
||||||
@@ -2532,7 +2589,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Mark notification read",
|
"summary": "Mark notification read",
|
||||||
@@ -2565,7 +2622,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Mark all notifications read",
|
"summary": "Mark all notifications read",
|
||||||
@@ -2618,7 +2675,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Returns the generated OpenAPI JSON document.",
|
"description": "Returns the generated OpenAPI JSON document.",
|
||||||
"operationId": "ApiController.openApi",
|
"operationId": "ApiController.openApi",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -2682,7 +2739,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Assigned reports",
|
"summary": "Assigned reports",
|
||||||
@@ -2733,7 +2790,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Open unassigned reports",
|
"summary": "Open unassigned reports",
|
||||||
@@ -2784,7 +2841,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Other operator reports",
|
"summary": "Other operator reports",
|
||||||
@@ -2797,7 +2854,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"description": "Checks whether MySQL is reachable.",
|
"description": "Checks whether MySQL is reachable.",
|
||||||
"operationId": "ApiController.ready",
|
"operationId": "ApiController.ready",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"content": {
|
"content": {
|
||||||
@@ -2875,7 +2932,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "List reports",
|
"summary": "List reports",
|
||||||
@@ -2886,7 +2943,7 @@
|
|||||||
"post": {
|
"post": {
|
||||||
"description": "Creates a citizen urban issue report.",
|
"description": "Creates a citizen urban issue report.",
|
||||||
"operationId": "ReportController.create",
|
"operationId": "ReportController.create",
|
||||||
"parameters": [],
|
"parameters": [ ],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -2920,7 +2977,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Create report",
|
"summary": "Create report",
|
||||||
@@ -2964,7 +3021,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Report detail",
|
"summary": "Report detail",
|
||||||
@@ -3021,7 +3078,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Assign team",
|
"summary": "Assign team",
|
||||||
@@ -3078,7 +3135,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Add feedback",
|
"summary": "Add feedback",
|
||||||
@@ -3135,7 +3192,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Flag report",
|
"summary": "Flag report",
|
||||||
@@ -3179,7 +3236,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Intervention summary",
|
"summary": "Intervention summary",
|
||||||
@@ -3236,7 +3293,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Upload media",
|
"summary": "Upload media",
|
||||||
@@ -3280,7 +3337,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "List messages",
|
"summary": "List messages",
|
||||||
@@ -3335,7 +3392,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Add message",
|
"summary": "Add message",
|
||||||
@@ -3401,7 +3458,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Flag message",
|
"summary": "Flag message",
|
||||||
@@ -3458,7 +3515,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Update report status",
|
"summary": "Update report status",
|
||||||
@@ -3505,7 +3562,7 @@
|
|||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"bearerAuth": []
|
"bearerAuth": [ ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"summary": "Take report",
|
"summary": "Take report",
|
||||||
|
|||||||
+20
-26
@@ -239,37 +239,31 @@ Json::Value AuthService::changePassword(const auth::UserContext &user,
|
|||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value AuthService::currentUser(const auth::UserContext &user)
|
Json::Value AuthService::editUser(const auth::UserContext &user, Json::Value::const_iterator::reference body) {
|
||||||
{
|
const auto allowedFields = {"first_name", "last_name", "phone"};
|
||||||
auto db = drogon::app().getDbClient();
|
auto db = drogon::app().getDbClient();
|
||||||
const auto result = db->execSqlSync(
|
bool hasUpdates = false;
|
||||||
"SELECT id, first_name, last_name, email, fiscal_code, phone, points, "
|
|
||||||
"must_change_password FROM users WHERE id = ?",
|
|
||||||
user.id);
|
|
||||||
|
|
||||||
auto response = success();
|
for (const auto& field : allowedFields) {
|
||||||
if (!result.empty())
|
if (body.isMember(field)) {
|
||||||
{
|
if (!body[field].isString()) {
|
||||||
response["user"]["id"] = Json::Int64(result[0]["id"].as<long long>());
|
return failure("invalid_field_type");
|
||||||
response["user"]["first_name"] = result[0]["first_name"].as<std::string>();
|
|
||||||
response["user"]["last_name"] = result[0]["last_name"].as<std::string>();
|
|
||||||
response["user"]["email"] = result[0]["email"].as<std::string>();
|
|
||||||
response["user"]["fiscal_code"] = result[0]["fiscal_code"].as<std::string>();
|
|
||||||
response["user"]["phone"] = result[0]["phone"].as<std::string>();
|
|
||||||
response["user"]["points"] = result[0]["points"].as<int>();
|
|
||||||
response["user"]["must_change_password"] =
|
|
||||||
result[0]["must_change_password"].as<bool>();
|
|
||||||
response["user"]["role"] = user.role;
|
|
||||||
for (const auto &role : user.roles)
|
|
||||||
{
|
|
||||||
response["user"]["roles"].append(role);
|
|
||||||
}
|
}
|
||||||
for (const auto &permission : user.permissions)
|
|
||||||
{
|
db->execSqlSync(
|
||||||
response["user"]["permissions"].append(permission);
|
"UPDATE users SET " + std::string(field) + " = ? WHERE id = ?",
|
||||||
|
body[field].asString(),
|
||||||
|
user.id
|
||||||
|
);
|
||||||
|
hasUpdates = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response;
|
|
||||||
|
if (!hasUpdates) {
|
||||||
|
return failure("missing_fields");
|
||||||
|
}
|
||||||
|
|
||||||
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value AuthService::editUser(const auth::UserContext &user, Json::Value::const_iterator::reference body) {
|
Json::Value AuthService::editUser(const auth::UserContext &user, Json::Value::const_iterator::reference body) {
|
||||||
|
|||||||
Reference in New Issue
Block a user