11use crate :: models:: project_alias:: { NewProjectAlias , ProjectAlias as ProjectAliasModel } ;
2- use crate :: models:: user:: User ;
32use crate :: state:: AppState ;
3+ use crate :: utils:: auth:: AuthenticatedUser ;
44use crate :: { db_query, get_db_conn} ;
55use aide:: NoApi ;
66use axum:: Json ;
77use axum:: extract:: Path ;
88use axum:: {
9- Extension ,
109 extract:: State ,
1110 http:: StatusCode ,
1211 response:: { IntoResponse , Response } ,
@@ -35,13 +34,8 @@ pub struct ProjectAliasesResponse {
3534/// Handler for the project aliases
3635pub async fn project_aliases (
3736 State ( app_state) : State < AppState > ,
38- user : NoApi < Option < Extension < User > > > ,
37+ NoApi ( AuthenticatedUser ( current_user ) ) : NoApi < AuthenticatedUser > ,
3938) -> Result < Json < ProjectAliasesResponse > , Response > {
40- // get current user
41- let current_user = user
42- . 0
43- . expect ( "User should be authenticated since middleware validated authentication" )
44- . 0 ;
4539
4640 // get database connection
4741 let mut conn = get_db_conn ! ( app_state) ;
@@ -78,13 +72,9 @@ pub async fn project_aliases(
7872
7973pub async fn add_project_alias (
8074 State ( app_state) : State < AppState > ,
81- user : NoApi < Option < Extension < User > > > ,
75+ NoApi ( AuthenticatedUser ( current_user ) ) : NoApi < AuthenticatedUser > ,
8276 Path ( ( id, alias_id) ) : Path < ( i32 , i32 ) > ,
8377) -> Result < StatusCode , Response > {
84- let current_user = user
85- . 0
86- . expect ( "User should be authenticated since middleware validated authentication" )
87- . 0 ;
8878
8979 let mut conn = get_db_conn ! ( app_state) ;
9080
@@ -104,13 +94,9 @@ pub async fn add_project_alias(
10494
10595pub async fn delete_project_alias (
10696 State ( app_state) : State < AppState > ,
107- user : NoApi < Option < Extension < User > > > ,
97+ NoApi ( AuthenticatedUser ( current_user ) ) : NoApi < AuthenticatedUser > ,
10898 Path ( id) : Path < i32 > ,
10999) -> Result < StatusCode , Response > {
110- let current_user = user
111- . 0
112- . expect ( "User should be authenticated since middleware validated authentication" )
113- . 0 ;
114100
115101 let mut conn = get_db_conn ! ( app_state) ;
116102
0 commit comments