Skip to content

controllers/user/session: Replace r2d2 with deadpool #8440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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