File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,7 @@ pub fn authorize(req: &mut dyn Request) -> AppResult<Response> {
89
89
}
90
90
}
91
91
92
- // Fetch the access token from github using the code we just got
93
-
92
+ // Fetch the access token from GitHub using the code we just got
94
93
let code = AuthorizationCode :: new ( code) ;
95
94
let token = req
96
95
. app ( )
@@ -99,8 +98,12 @@ pub fn authorize(req: &mut dyn Request) -> AppResult<Response> {
99
98
. map_err ( |e| e. compat ( ) )
100
99
. chain_error ( || server_error ( "Error obtaining token" ) ) ?;
101
100
let token = token. access_token ( ) ;
101
+
102
+ // Fetch the user info from GitHub using the access token we just got and create a user record
102
103
let ghuser = github:: github_api :: < GithubUser > ( req. app ( ) , "/user" , token) ?;
103
104
let user = ghuser. save_to_database ( & token. secret ( ) , & * req. db_conn ( ) ?) ?;
105
+
106
+ // Log in by setting a cookie and the middleware authentication
104
107
req. session ( )
105
108
. insert ( "user_id" . to_string ( ) , user. id . to_string ( ) ) ;
106
109
req. mut_extensions ( ) . insert ( TrustedUserId ( user. id ) ) ;
You can’t perform that action at this time.
0 commit comments