MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / register

Function register

examples/loco_seaography/src/controllers/auth.rs:32–64  ·  view source on GitHub ↗
(
    State(ctx): State<AppContext>,
    Json(params): Json<RegisterParams>,
)

Source from the content-addressed store, hash-verified

30/// welcome email to the user
31#[debug_handler]
32async 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, &params).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 = &params.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.

Callers

nothing calls this directly

Calls 3

jsonFunction · 0.85
into_active_modelMethod · 0.80
verifiedMethod · 0.45

Tested by

no test coverage detected