Skip to content

Commit

Permalink
Merge torrust#675: Rename email config option
Browse files Browse the repository at this point in the history
35528b4 feat: [torrust#674] rename email config option (Jose Celano)

Pull request description:

  From:

  ```toml
  [registration]

  [registration.email]
  required = true
  verified = true
  ```

  To:

  ```toml
  [registration]

  [registration.email]
  required = true
  verification_required = true
  ```

ACKs for top commit:
  josecelano:
    ACK 35528b4

Tree-SHA512: b46e635eefbfe26826cb11935dd9046f0ee6b6074bf4352749f13173cfe9cc9b841091374cc4159dffaa860a2a214aaafbf4bfd994d4943c9d3cb0de66bb7e93
  • Loading branch information
josecelano committed Jul 11, 2024
2 parents f41b725 + 35528b4 commit 152ca2d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/config/v2/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ pub struct Email {

/// Whether or not email is verified.
#[serde(default = "Email::default_verified")]
pub verified: bool,
pub verification_required: bool,
}

impl Default for Email {
fn default() -> Self {
Self {
required: Self::default_required(),
verified: Self::default_verified(),
verification_required: Self::default_verified(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Service {
// Fail login if email verification is required and this email is not verified
if let Some(registration) = &settings.registration {
if let Some(email) = &registration.email {
if email.verified && !user_profile.email_verified {
if email.verification_required && !user_profile.email_verified {
return Err(ServiceError::EmailNotVerified);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl RegistrationService {

match &registration.email {
Some(email) => {
if email.verified {
if email.verification_required {
// Email verification is enabled
if let Some(email) = opt_email {
let mail_res = self
Expand Down
4 changes: 2 additions & 2 deletions tests/common/contexts/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub struct Registration {
#[derive(Deserialize, Serialize, PartialEq, Debug, Clone)]
pub struct Email {
pub required: bool,
pub verified: bool,
pub verification_required: bool,
}

#[derive(Deserialize, Serialize, PartialEq, Debug, Clone)]
Expand Down Expand Up @@ -264,7 +264,7 @@ impl From<DomainEmail> for Email {
fn from(email: DomainEmail) -> Self {
Self {
required: email.required,
verified: email.verified,
verification_required: email.verification_required,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/environments/isolated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn ephemeral(temp_dir: &TempDir) -> config::Settings {
configuration.registration = Some(Registration {
email: Some(Email {
required: false,
verified: false,
verification_required: false,
}),
});

Expand Down

0 comments on commit 152ca2d

Please sign in to comment.