11use super :: update:: UserConfirmEmail ;
22use crate :: app:: AppState ;
33use crate :: auth:: AuthCheck ;
4- use crate :: controllers:: helpers:: ok_true ;
4+ use crate :: controllers:: helpers:: OkResponse ;
55use crate :: models:: Email ;
66use crate :: util:: errors:: AppResult ;
77use crate :: util:: errors:: { BoxedAppError , bad_request} ;
88use axum:: extract:: Path ;
9- use axum:: response:: Response ;
109use crates_io_database:: schema:: emails;
1110use diesel:: dsl:: sql;
1211use diesel:: prelude:: * ;
@@ -22,9 +21,12 @@ use http::request::Parts;
2221 ( "email_token" = String , Path , description = "Secret verification token sent to the user's email address" ) ,
2322 ) ,
2423 tag = "users" ,
25- responses( ( status = 200 , description = "Successful Response" ) ) ,
24+ responses( ( status = 200 , description = "Successful Response" , body = inline ( OkResponse ) ) ) ,
2625) ]
27- pub async fn confirm_user_email ( state : AppState , Path ( token) : Path < String > ) -> AppResult < Response > {
26+ pub async fn confirm_user_email (
27+ state : AppState ,
28+ Path ( token) : Path < String > ,
29+ ) -> AppResult < OkResponse > {
2830 let mut conn = state. db_write ( ) . await ?;
2931
3032 let updated_rows = diesel:: update ( emails:: table. filter ( emails:: token. eq ( & token) ) )
@@ -36,7 +38,7 @@ pub async fn confirm_user_email(state: AppState, Path(token): Path<String>) -> A
3638 return Err ( bad_request ( "Email belonging to token not found." ) ) ;
3739 }
3840
39- ok_true ( )
41+ Ok ( OkResponse :: new ( ) )
4042}
4143
4244/// Regenerate and send an email verification token.
@@ -51,13 +53,13 @@ pub async fn confirm_user_email(state: AppState, Path(token): Path<String>) -> A
5153 ( "cookie" = [ ] ) ,
5254 ) ,
5355 tag = "users" ,
54- responses( ( status = 200 , description = "Successful Response" ) ) ,
56+ responses( ( status = 200 , description = "Successful Response" , body = inline ( OkResponse ) ) ) ,
5557) ]
5658pub async fn resend_email_verification (
5759 state : AppState ,
5860 Path ( param_user_id) : Path < i32 > ,
5961 req : Parts ,
60- ) -> AppResult < Response > {
62+ ) -> AppResult < OkResponse > {
6163 let mut conn = state. db_write ( ) . await ?;
6264 let auth = AuthCheck :: default ( ) . check ( & req, & mut conn) . await ?;
6365
@@ -91,7 +93,7 @@ pub async fn resend_email_verification(
9193 } )
9294 . await ?;
9395
94- ok_true ( )
96+ Ok ( OkResponse :: new ( ) )
9597}
9698
9799#[ cfg( test) ]
0 commit comments