1- use actix_error_proc :: { proof_route, HttpResult } ;
2- use actix_web:: { get , web , HttpRequest , HttpResponse , Responder } ;
1+ use actix_failwrap :: proof_route;
2+ use actix_web:: { HttpRequest , HttpResponse , get , web } ;
33use oauth2:: { AuthorizationCode , CsrfToken , Scope , TokenResponse } ;
44use serde:: Deserialize ;
55use uuid:: Uuid ;
@@ -22,7 +22,7 @@ pub struct AuthRequest {
2222}
2323
2424#[ get( "/auth" ) ]
25- pub async fn auth ( oauth : web:: Data < OAuthData > ) -> impl Responder {
25+ pub async fn auth ( oauth : web:: Data < OAuthData > ) -> HttpResponse {
2626 let ( auth_url, _csrf_token) = oauth
2727 . client
2828 . authorize_url ( CsrfToken :: new_random)
@@ -34,19 +34,19 @@ pub async fn auth(oauth: web::Data<OAuthData>) -> impl Responder {
3434 . finish ( )
3535}
3636
37- #[ get ( " /auth/me") ]
38- pub async fn me ( req : HttpRequest ) -> HttpResult < HttpErrors > {
37+ #[ proof_route ( "GET /auth/me") ]
38+ pub async fn me ( req : HttpRequest ) -> Result < HttpResponse , HttpErrors > {
3939 let user_info = jwt:: get_user_info ( & req) ?;
4040
4141 Ok ( HttpResponse :: Ok ( ) . json ( user_info) )
4242}
4343
44- #[ get ( " /auth/callback") ]
44+ #[ proof_route ( "GET /auth/callback") ]
4545async fn callback (
4646 state : web:: Data < AppState > ,
4747 query : web:: Query < AuthRequest > ,
4848 oauth_data : web:: Data < OAuthData > ,
49- ) -> HttpResult < HttpErrors > {
49+ ) -> Result < HttpResponse , HttpErrors > {
5050 let code = AuthorizationCode :: new ( query. code . clone ( ) ) ;
5151
5252 let token = oauth_data
@@ -90,11 +90,11 @@ struct GuestLoginRequest {
9090 guest_name : String ,
9191}
9292
93- #[ proof_route( post ( " /auth/guest") ) ]
93+ #[ proof_route( "POST /auth/guest") ]
9494async fn login_guest (
9595 state : web:: Data < AppState > ,
9696 body : web:: Json < GuestLoginRequest > ,
97- ) -> HttpResult < HttpErrors > {
97+ ) -> Result < HttpResponse , HttpErrors > {
9898 let guest_name = & body. guest_name ;
9999 let guest_uuid = Uuid :: new_v4 ( ) . to_string ( ) ;
100100
@@ -122,12 +122,12 @@ struct UpdateNameRequest {
122122 new_name : ArcStr ,
123123}
124124
125- #[ proof_route( post ( " /auth/update") ) ]
125+ #[ proof_route( "POST /auth/update") ]
126126async fn update_name (
127127 state : web:: Data < AppState > ,
128128 body : web:: Json < UpdateNameRequest > ,
129129 req : actix_web:: HttpRequest ,
130- ) -> HttpResult < HttpErrors > {
130+ ) -> Result < HttpResponse , HttpErrors > {
131131 let token_data = jwt:: get_user_info ( & req) ?;
132132
133133 if !token_data. is_guest {
0 commit comments