From 49e193768d01d7be3e7f9f1a1bd837926380ca5e Mon Sep 17 00:00:00 2001 From: antifallobst Date: Wed, 13 Sep 2023 07:23:26 +0200 Subject: [PATCH] refactor(api): renamend the field `name` of /user/id to `username` --- docs/README.md | 1 - docs/user/info.md | 11 ++++++----- src/api/user/data.rs | 2 +- src/api/user/handlers.rs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/README.md b/docs/README.md index 2c33d6e..2865dfe 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,7 +15,6 @@ __(ND)__ -> Not designed yet. - [X] `/delete` - [X] `/id` - [X] `/tokens` - - [X] `/tokens` - [ ] `/follows` - [ ] `/followers` - [ ] `/deactivate` diff --git a/docs/user/info.md b/docs/user/info.md index c68322c..7bdfcc5 100644 --- a/docs/user/info.md +++ b/docs/user/info.md @@ -17,11 +17,12 @@ Setting none or two parameters will result in a _400 Bad Request_ Response. ### 200 - Success __Content - JSON:__ -| Field | Description | + +| Field | Description | |----------|-------------------------------------------------------------------| -| id | The users unique id. | -| name | The users unique username. | -| joined | The datetime when the user joined. Represented as UNIX timestamp. | +| id | The users unique id. | +| username | The users unique username. | +| joined | The datetime when the user joined. Represented as UNIX timestamp. | | is_admin | A boolean if the user is an admin. | ### 400 - Error: Bad Request @@ -34,4 +35,4 @@ Blocked for security reasons. ### 404 - Error: Not Found -The user wasn't found. \ No newline at end of file +The user wasn't found. diff --git a/src/api/user/data.rs b/src/api/user/data.rs index 176e31a..ec7d1a2 100644 --- a/src/api/user/data.rs +++ b/src/api/user/data.rs @@ -15,7 +15,7 @@ pub enum InfoRequest { #[derive(Debug, Serialize)] pub struct InfoSuccess { pub id: i64, - pub name: String, + pub username: String, pub joined: i64, pub is_admin: bool, } diff --git a/src/api/user/handlers.rs b/src/api/user/handlers.rs index 1506eb1..d8679d7 100644 --- a/src/api/user/handlers.rs +++ b/src/api/user/handlers.rs @@ -1,6 +1,6 @@ use crate::{ - api::user::data, accounts::{Account, AccountFlags}, + api::user::data, security::is_sql_injection, }; use anyhow::Result; @@ -24,7 +24,7 @@ pub async fn info(pool: &PgPool, request: data::InfoRequest) -> Result