Skip to content

Commit fe5c383

Browse files
[48] User endpoints (#49)
* [48] implement user endpoints * [48] code cleanup * [48] fix user patch endpoint * [48] apply code review suggestions * [48] rename a selection of user methods * [48] apply code review suggestions separate user personalization from password changes
1 parent bbcd11d commit fe5c383

13 files changed

+668
-60
lines changed

.sqlx/query-24ea33795a75c8cf5a55ee719369e1860de7e7e46cddfd4dcb02a4452c9856bf.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-47ccf2685590c3652d1ea4e4fb764e714b357ec8353cde04d572bb63eb4b6397.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-50293c2e54af11d4c2a553e29b671cef087a159c6ee7182d8ca929ecb748f3b7.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-e9ee477fc969775d4a868a773162a3d14a8bdb38cbdad2069ecea6b100bee629.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/routes/auth.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ async fn auth_me(
6363
/// Providing the token either by including it in the
6464
/// request header or sending the cookie is required
6565
/// to perform any further operations.
66+
/// By default, the only existing account is the infrastructure admin
67+
/// with username and password "admin".
6668
#[utoipa::path(post, path = "/auth/login", request_body=LoginRequest,
6769
responses
6870
(
@@ -78,7 +80,7 @@ async fn auth_me(
7880
)
7981
)
8082
]
81-
pub async fn auth_login(
83+
async fn auth_login(
8284
cookies: Cookies,
8385
State(state): State<AppState>,
8486
Json(body): Json<LoginRequest>,

src/routes/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ mod swagger;
1414
mod team_routes;
1515
mod teapot;
1616
mod tournament_routes;
17+
mod user_routes;
1718
mod version;
1819

1920
pub fn routes() -> Router<AppState> {
@@ -29,6 +30,7 @@ pub fn routes() -> Router<AppState> {
2930
.merge(attendee_routes::route())
3031
.merge(motion_routes::route())
3132
.merge(debate_routes::route())
33+
.merge(user_routes::route())
3234
.merge(location_routes::route())
3335
.merge(room_routes::route())
3436
}

src/routes/swagger.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use utoipa::OpenApi;
33
use utoipa_swagger_ui::SwaggerUi;
44

55
use crate::routes::auth;
6+
use crate::routes::user_routes;
67
use crate::setup::AppState;
78

89
use crate::routes::attendee_routes;
@@ -20,7 +21,9 @@ use crate::tournament::motion;
2021
use crate::tournament::room;
2122
use crate::tournament::team;
2223
use crate::users::permissions;
24+
use crate::users::photourl;
2325
use crate::users::roles;
26+
use crate::users::UserPatch;
2427

2528
use super::health_check;
2629
use super::teapot;
@@ -66,6 +69,7 @@ pub fn route() -> Router<AppState> {
6669
attendee_routes::delete_attendee_by_id,
6770
auth::auth_login,
6871
auth::auth_me,
72+
auth::auth_clear,
6973
location_routes::create_location,
7074
location_routes::get_locations,
7175
location_routes::get_location_by_id,
@@ -76,6 +80,12 @@ pub fn route() -> Router<AppState> {
7680
room_routes::get_room_by_id,
7781
room_routes::patch_room_by_id,
7882
room_routes::delete_room_by_id,
83+
user_routes::get_users,
84+
user_routes::create_user,
85+
user_routes::get_user_by_id,
86+
user_routes::patch_user_by_id,
87+
user_routes::delete_user_by_id,
88+
user_routes::change_user_password,
7989
),
8090
components(schemas(
8191
version::VersionDetails,
@@ -98,6 +108,11 @@ pub fn route() -> Router<AppState> {
98108
location::LocationPatch,
99109
room::Room,
100110
room::RoomPatch,
111+
user_routes::UserWithPassword,
112+
user_routes::UserPasswordPatch,
113+
crate::users::UserPatch,
114+
crate::users::User,
115+
photourl::PhotoUrl
101116
))
102117
)]
103118

0 commit comments

Comments
 (0)