Skip to content

Commit

Permalink
feat: [#674] rename email config option
Browse files Browse the repository at this point in the history
From:

```toml
[registration]

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

To:

```toml
[registration]

[registration.email]
required = true
verification_required = true
```
  • Loading branch information
josecelano committed Jul 11, 2024
1 parent f41b725 commit 35528b4
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 35528b4

Please sign in to comment.