@@ -7,10 +7,10 @@ use actix_web::http::header::LOCATION;
7
7
8
8
const REDIRECT_URL : & str = "https://kenkoooo.com/atcoder/" ;
9
9
10
- #[ async_trait]
10
+ #[ async_trait( ? Send ) ]
11
11
pub trait Authentication {
12
- async fn get_token ( & self , code : & str ) -> Result < String , reqwest :: Error > ;
13
- async fn get_user_id ( & self , token : & str ) -> Result < GitHubUserResponse , reqwest :: Error > ;
12
+ async fn get_token ( & self , code : & str ) -> Result < String > ;
13
+ async fn get_user_id ( & self , token : & str ) -> Result < GitHubUserResponse > ;
14
14
}
15
15
16
16
#[ derive( Serialize ) ]
@@ -37,9 +37,9 @@ pub struct GitHubAuthentication {
37
37
client_secret : String ,
38
38
}
39
39
40
- #[ async_trait]
40
+ #[ async_trait( ? Send ) ]
41
41
impl Authentication for GitHubAuthentication {
42
- async fn get_token ( & self , code : & str ) -> Result < String , reqwest :: Error > {
42
+ async fn get_token ( & self , code : & str ) -> Result < String > {
43
43
let request = TokenRequest {
44
44
client_id : self . client_id . to_owned ( ) ,
45
45
client_secret : self . client_secret . to_owned ( ) ,
@@ -51,21 +51,21 @@ impl Authentication for GitHubAuthentication {
51
51
. header ( "Accept" , "application/json" )
52
52
. json ( & request)
53
53
. send ( )
54
- . await ?
54
+ . await . map_err ( error :: ErrorInternalServerError ) ?
55
55
. json ( )
56
- . await ?;
56
+ . await . map_err ( error :: ErrorInternalServerError ) ?;
57
57
Ok ( response. access_token )
58
58
}
59
- async fn get_user_id ( & self , access_token : & str ) -> Result < GitHubUserResponse , reqwest :: Error > {
59
+ async fn get_user_id ( & self , access_token : & str ) -> Result < GitHubUserResponse > {
60
60
let token_header = format ! ( "token {}" , access_token) ;
61
61
let client = reqwest:: Client :: new ( ) ;
62
62
let response: GitHubUserResponse = client
63
63
. get ( "https://api.github.com/user" )
64
64
. header ( "Authorization" , token_header)
65
65
. send ( )
66
- . await ?
66
+ . await . map_err ( error :: ErrorInternalServerError ) ?
67
67
. json ( )
68
- . await ?;
68
+ . await . map_err ( error :: ErrorInternalServerError ) ?;
69
69
Ok ( response)
70
70
}
71
71
}
0 commit comments