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:
@@ -41,13 +41,13 @@ pub async fn get_permission_list(
|
||||
Query(meta): Query<MetaRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::ReadListPermissions],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => PermissionsService::get_permission_list(&state, meta).await,
|
||||
Ok((_user, state)) => PermissionsService::get_permission_list(&state, meta).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -70,13 +70,13 @@ pub async fn get_permission_by_id(
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::ReadDetailPermissions],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => PermissionsService::get_permission_by_id(&state, id).await,
|
||||
Ok((_user, state)) => PermissionsService::get_permission_by_id(&state, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -99,13 +99,13 @@ pub async fn post_create_permission(
|
||||
Json(payload): Json<PermissionsRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::CreatePermissions],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => PermissionsService::create_role(&state, payload).await,
|
||||
Ok((_user, state)) => PermissionsService::create_role(&state, payload).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -129,13 +129,13 @@ pub async fn put_update_permission(
|
||||
Json(payload): Json<PermissionsUpdateRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::UpdatePermissions],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => PermissionsService::update_permission(&state, payload, id).await,
|
||||
Ok((_user, state)) => PermissionsService::update_permission(&state, payload, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -157,13 +157,13 @@ pub async fn delete_permission(
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::DeletePermissions],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => PermissionsService::delete_permission(&state, id).await,
|
||||
Ok((_user, state)) => PermissionsService::delete_permission(&state, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user