Skip to content

Commit 30f8dff

Browse files
committed
Add some more comments
1 parent 535665a commit 30f8dff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/controllers/user/session.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ pub fn authorize(req: &mut dyn Request) -> AppResult<Response> {
8989
}
9090
}
9191

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
9493
let code = AuthorizationCode::new(code);
9594
let token = req
9695
.app()
@@ -99,8 +98,12 @@ pub fn authorize(req: &mut dyn Request) -> AppResult<Response> {
9998
.map_err(|e| e.compat())
10099
.chain_error(|| server_error("Error obtaining token"))?;
101100
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
102103
let ghuser = github::github_api::<GithubUser>(req.app(), "/user", token)?;
103104
let user = ghuser.save_to_database(&token.secret(), &*req.db_conn()?)?;
105+
106+
// Log in by setting a cookie and the middleware authentication
104107
req.session()
105108
.insert("user_id".to_string(), user.id.to_string());
106109
req.mut_extensions().insert(TrustedUserId(user.id));

0 commit comments

Comments
 (0)