From 51f9b915a001a7dd6e70954a0c34604b54810890 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 18 May 2022 16:14:58 -0600 Subject: [PATCH] WIP --- crates/collab/src/api.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) 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)) }