Skip to content

Commit 3b01529

Browse files
committed
add feature to restrict full email address not by domain
1 parent a265c9c commit 3b01529

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

config_sample.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ auth:
2020

2121
# # restrict domain. (optional)
2222
# domain:
23-
# - yourdomain.com
23+
# - yourdomain.com # restrict by domain
24+
# - [email protected] # or specific address
2425

2526
# document root for static files
2627
htdocs: ./

httpd.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,15 @@ func restrictDomain(domain []string) martini.Handler {
208208
var user *User
209209
if len(domain) > 0 {
210210
for _, d := range domain {
211-
if strings.HasSuffix(email, "@"+d) {
212-
user = &User{email}
213-
break
211+
if strings.Contains(d, "@") {
212+
if d == email {
213+
user = &User{email}
214+
}
215+
} else {
216+
if strings.HasSuffix(email, "@"+d) {
217+
user = &User{email}
218+
break
219+
}
214220
}
215221
}
216222
} else {

0 commit comments

Comments
 (0)