feat: Add axum-extra dependency and implement typed headers
feat: Define unique index on users table for email and fix minor syntax error refactor: Update permissions_guard to use claims from JWT and improve user retrieval refactor: Modify user-related service methods to accept user details directly fix: Update token generation functions to include user ID and permissions test: Update Google OAuth flow tests to reflect changes in token generation
This commit is contained in:
@@ -36,13 +36,13 @@ pub async fn get_gacha_item_list(
|
||||
Query(meta): Query<MetaRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::ReadListGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::get_gacha_item_list(&state, meta).await,
|
||||
Ok((_user, state)) => GachaItemService::get_gacha_item_list(&state, meta).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -65,13 +65,13 @@ pub async fn get_gacha_item_by_id(
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::ReadDetailGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::get_gacha_item_by_id(&state, id).await,
|
||||
Ok((_user, state)) => GachaItemService::get_gacha_item_by_id(&state, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -94,13 +94,13 @@ pub async fn post_create_gacha_item(
|
||||
Json(payload): Json<GachaItemRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::CreateGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::create_gacha_item(&state, payload).await,
|
||||
Ok((_user, state)) => GachaItemService::create_gacha_item(&state, payload).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -124,13 +124,13 @@ pub async fn put_update_gacha_item(
|
||||
Json(payload): Json<GachaItemUpdateRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::UpdateGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::update_gacha_item(&state, payload, id).await,
|
||||
Ok((_user, state)) => GachaItemService::update_gacha_item(&state, payload, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -152,13 +152,13 @@ pub async fn delete_gacha_item(
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::DeleteGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::delete_gacha_item(&state, id).await,
|
||||
Ok((_user, state)) => GachaItemService::delete_gacha_item(&state, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user