Skip to content

Commit

Permalink
controllers/user/session: Replace r2d2 with deadpool (#8440)
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 authored Apr 10, 2024
1 parent cd48386 commit 77d55e9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/controllers/user/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ pub async fn authorize(
let app_clone = app.clone();
let request_log = req.request_log().clone();

spawn_blocking(move || {
let conn = app.db_write_async().await?;
conn.interact(move |conn| {
// Make sure that the state we just got matches the session state that we
// should have issued earlier.
let session_state = session.remove("github_oauth_state").map(CsrfToken::new);
Expand All @@ -108,15 +109,14 @@ pub async fn authorize(

// Fetch the user info from GitHub using the access token we just got and create a user record
let ghuser = Handle::current().block_on(app.github.current_user(token))?;
let user =
save_user_to_database(&ghuser, token.secret(), &app.emails, &mut *app.db_write()?)?;
let user = save_user_to_database(&ghuser, token.secret(), &app.emails, conn)?;

// Log in by setting a cookie and the middleware authentication
session.insert("user_id".to_string(), user.id.to_string());

Ok(())
})
.await?;
.await??;

super::me::me(app_clone, req).await
}
Expand Down

0 comments on commit 77d55e9

Please sign in to comment.