mirror of
https://github.com/foxcpp/maddy.git
synced 2025-04-04 21:47:40 +03:00
Extract mapping lookup from loop
This commit is contained in:
parent
9a87d73383
commit
1a603a4e53
1 changed files with 16 additions and 16 deletions
|
@ -9,12 +9,6 @@ import (
|
|||
)
|
||||
|
||||
func AuthorizeEmailUse(ctx context.Context, username string, addrs []string, mapping module.Table) (bool, error) {
|
||||
for _, addr := range addrs {
|
||||
_, domain, err := address.Split(addr)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("authz: %w", err)
|
||||
}
|
||||
|
||||
var validEmails []string
|
||||
if multi, ok := mapping.(module.MultiTable); ok {
|
||||
validEmails, err = multi.LookupMulti(ctx, username)
|
||||
|
@ -31,6 +25,12 @@ func AuthorizeEmailUse(ctx context.Context, username string, addrs []string, map
|
|||
}
|
||||
}
|
||||
|
||||
for _, addr := range addrs {
|
||||
_, domain, err := address.Split(addr)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("authz: %w", err)
|
||||
}
|
||||
|
||||
for _, ent := range validEmails {
|
||||
if ent == domain || ent == "*" || ent == addr {
|
||||
return true, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue