(
State(ctx): State<AppContext>,
Json(params): Json<RegisterParams>,
)
| 30 | /// welcome email to the user |
| 31 | #[debug_handler] |
| 32 | async fn register( |
| 33 | State(ctx): State<AppContext>, |
| 34 | Json(params): Json<RegisterParams>, |
| 35 | ) -> Result<Response> { |
| 36 | let res = users::Model::create_with_password(&ctx.db, ¶ms).await; |
| 37 | |
| 38 | let user = match res { |
| 39 | Ok(user) => user, |
| 40 | Err(err) => { |
| 41 | tracing::info!( |
| 42 | message = err.to_string(), |
| 43 | user_email = ¶ms.email, |
| 44 | "could not register user", |
| 45 | ); |
| 46 | return format::json(()); |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | // Skip email verification, all new registrations are considered verified |
| 51 | let _user = user.into_active_model().verified(&ctx.db).await?; |
| 52 | |
| 53 | // Skip sending verification email as we don't have a mail server |
| 54 | /* |
| 55 | let user = user |
| 56 | .into_active_model() |
| 57 | .set_email_verification_sent(&ctx.db) |
| 58 | .await?; |
| 59 | |
| 60 | AuthMailer::send_welcome(&ctx, &user).await?; |
| 61 | */ |
| 62 | |
| 63 | format::json(()) |
| 64 | } |
| 65 | |
| 66 | /// Verify register user. if the user not verified his email, he can't login to |
| 67 | /// the system. |
nothing calls this directly
no test coverage detected