mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-09-19 01:05:55 +00:00
chore: add email blocklist unit test
This commit is contained in:
parent
cf1fda81f6
commit
a511e37572
9 changed files with 92 additions and 21 deletions
|
@ -201,7 +201,7 @@ func NewUserPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if !validation.IsEmailDomainAllowed(u.Email) {
|
||||
if _, ok := validation.IsEmailDomainAllowed(u.Email); !ok {
|
||||
ctx.Flash.Warning(ctx.Tr("form.email_domain_is_not_allowed", u.Email))
|
||||
}
|
||||
|
||||
|
@ -421,7 +421,7 @@ func EditUserPost(ctx *context.Context) {
|
|||
}
|
||||
return
|
||||
}
|
||||
if !validation.IsEmailDomainAllowed(form.Email) {
|
||||
if _, ok := validation.IsEmailDomainAllowed(form.Email); !ok {
|
||||
ctx.Flash.Warning(ctx.Tr("form.email_domain_is_not_allowed", form.Email))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -452,7 +452,10 @@ func SignUpPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if !form.IsEmailDomainAllowed() {
|
||||
if emailValid, ok := form.IsEmailDomainAllowed(); !emailValid {
|
||||
ctx.RenderWithErr(ctx.Tr("form.email_invalid"), tplSignUp, form)
|
||||
return
|
||||
} else if !ok {
|
||||
ctx.RenderWithErr(ctx.Tr("auth.email_domain_blacklisted"), tplSignUp, &form)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -226,7 +226,10 @@ func LinkAccountPostRegister(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
if !form.IsEmailDomainAllowed() {
|
||||
if emailValid, ok := form.IsEmailDomainAllowed(); !emailValid {
|
||||
ctx.RenderWithErr(ctx.Tr("form.email_invalid"), tplSignUp, form)
|
||||
return
|
||||
} else if !ok {
|
||||
ctx.RenderWithErr(ctx.Tr("auth.email_domain_blacklisted"), tplLinkAccount, &form)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue