diff --git a/crates/api/src/local_user.rs b/crates/api/src/local_user.rs index 962124e2a..d080010e9 100644 --- a/crates/api/src/local_user.rs +++ b/crates/api/src/local_user.rs @@ -102,6 +102,8 @@ impl Perform for Login { &context.secret().jwt_secret, &context.settings().hostname, )?), + verify_email_sent: false, + registration_created: false, }) } } @@ -290,6 +292,8 @@ impl Perform for SaveUserSettings { &context.secret().jwt_secret, &context.settings().hostname, )?), + verify_email_sent: false, + registration_created: false, }) } } @@ -338,6 +342,8 @@ impl Perform for ChangePassword { &context.secret().jwt_secret, &context.settings().hostname, )?), + verify_email_sent: false, + registration_created: false, }) } } @@ -806,6 +812,8 @@ impl Perform for PasswordChange { &context.secret().jwt_secret, &context.settings().hostname, )?), + verify_email_sent: false, + registration_created: false, }) } } diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 2b36ae75b..5a817a808 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -83,6 +83,8 @@ pub struct LoginResponse { /// This is None in response to `Register` if email verification is enabled, and in response to /// `DeleteAccount`. pub jwt: Option, + pub registration_created: bool, + pub verify_email_sent: bool, } #[derive(Serialize, Deserialize)] diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index c9ccf4ab5..1f0de6432 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -247,7 +247,7 @@ impl PerformCrud for Register { } // Log the user in directly if email verification is not required - let jwt = if email_verification { + let login_response = if email_verification { send_verification_email( inserted_local_user.id, // we check at the beginning of this method that email is set @@ -256,15 +256,29 @@ impl PerformCrud for Register { context, ) .await?; - None + LoginResponse { + jwt: None, + verify_email_sent: true, + registration_created: false, + } + } else if require_application { + LoginResponse { + jwt: None, + verify_email_sent: false, + registration_created: true, + } } else { - Some(Claims::jwt( - inserted_local_user.id.0, - &context.secret().jwt_secret, - &context.settings().hostname, - )?) + LoginResponse { + jwt: Some(Claims::jwt( + inserted_local_user.id.0, + &context.secret().jwt_secret, + &context.settings().hostname, + )?), + verify_email_sent: false, + registration_created: false, + } }; - // TODO this needs a "registration created" type response - Ok(LoginResponse { jwt }) + + Ok(login_response) } } diff --git a/crates/api_crud/src/user/delete.rs b/crates/api_crud/src/user/delete.rs index 0add7e958..2fdf9412c 100644 --- a/crates/api_crud/src/user/delete.rs +++ b/crates/api_crud/src/user/delete.rs @@ -47,6 +47,10 @@ impl PerformCrud for DeleteAccount { }) .await??; - Ok(LoginResponse { jwt: None }) + Ok(LoginResponse { + jwt: None, + verify_email_sent: false, + registration_created: false, + }) } }