Skip to content

Commit 0027980

Browse files
committed
Add translatable errors for the email policy constraints
1 parent b603b32 commit 0027980

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

crates/policy/src/model.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ pub enum Code {
3737

3838
/// The email domain is banned.
3939
EmailDomainBanned,
40+
41+
/// The email address is not allowed.
42+
EmailNotAllowed,
43+
44+
/// The email address is banned.
45+
EmailBanned,
4046
}
4147

4248
impl Code {
@@ -50,6 +56,8 @@ impl Code {
5056
Self::UsernameAllNumeric => "username-all-numeric",
5157
Self::EmailDomainNotAllowed => "email-domain-not-allowed",
5258
Self::EmailDomainBanned => "email-domain-banned",
59+
Self::EmailNotAllowed => "email-not-allowed",
60+
Self::EmailBanned => "email-banned",
5361
}
5462
}
5563
}

templates/components/field.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
{{ _("mas.errors.email_domain_not_allowed") }}
7474
{% elif error.code == "email-domain-banned" %}
7575
{{ _("mas.errors.email_domain_banned") }}
76+
{% elif error.code == "email-not-allowed" %}
77+
{{ _("mas.errors.email_not_allowed") }}
78+
{% elif error.code == "email-banned" %}
79+
{{ _("mas.errors.email_banned") }}
7680
{% else %}
7781
{{ _("mas.errors.denied_policy", policy=error.message) }}
7882
{% endif %}

translations/en.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@
299299
},
300300
"denied_policy": "Denied by policy: %(policy)s",
301301
"@denied_policy": {
302-
"context": "components/errors.html:17:7-58, components/field.html:77:19-70"
302+
"context": "components/errors.html:17:7-58, components/field.html:81:19-70"
303+
},
304+
"email_banned": "Email is banned by the server policy",
305+
"@email_banned": {
306+
"context": "components/field.html:79:19-47"
303307
},
304308
"email_domain_banned": "Email domain is banned by the server policy",
305309
"@email_domain_banned": {
@@ -309,6 +313,10 @@
309313
"@email_domain_not_allowed": {
310314
"context": "components/field.html:73:19-59"
311315
},
316+
"email_not_allowed": "Email is not allowed by the server policy",
317+
"@email_not_allowed": {
318+
"context": "components/field.html:77:19-52"
319+
},
312320
"field_required": "This field is required",
313321
"@field_required": {
314322
"context": "components/field.html:60:17-47"
@@ -319,7 +327,7 @@
319327
},
320328
"password_mismatch": "Password fields don't match",
321329
"@password_mismatch": {
322-
"context": "components/errors.html:13:7-40, components/field.html:80:17-50"
330+
"context": "components/errors.html:13:7-40, components/field.html:84:17-50"
323331
},
324332
"rate_limit_exceeded": "You've made too many requests in a short period. Please wait a few minutes and try again.",
325333
"@rate_limit_exceeded": {
@@ -416,7 +424,7 @@
416424
},
417425
"or_separator": "Or",
418426
"@or_separator": {
419-
"context": "components/field.html:99:10-31",
427+
"context": "components/field.html:103:10-31",
420428
"description": "Separator between the login methods"
421429
},
422430
"policy_violation": {

0 commit comments

Comments
 (0)