diff --git a/crates/collab/src/api.rs b/crates/collab/src/api.rs index f325d01004..24a1989ae7 100644 --- a/crates/collab/src/api.rs +++ b/crates/collab/src/api.rs @@ -82,24 +82,22 @@ async fn create_user( Json(params): Json, Extension(app): Extension>, ) -> Result> { - let user = if let Some(invite_code) = params.invite_code { - let user_id = app - .db + let user_id = if let Some(invite_code) = params.invite_code { + app.db .redeem_invite_code(&invite_code, ¶ms.github_login) .await? } else { - let user_id = app - .db + app.db .create_user(¶ms.github_login, params.admin) - .await?; - - let user = app - .db - .get_user_by_id(user_id) .await? - .ok_or_else(|| anyhow!("couldn't find the user we just created"))? }; + let user = app + .db + .get_user_by_id(user_id) + .await? + .ok_or_else(|| anyhow!("couldn't find the user we just created"))?; + Ok(Json(user)) }