From 3b015290c7582110509e265081b10f486e05a005 Mon Sep 17 00:00:00 2001 From: Daisuke Murase Date: Thu, 14 Aug 2014 12:19:25 +0900 Subject: [PATCH] add feature to restrict full email address not by domain --- config_sample.yml | 3 ++- httpd.go | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config_sample.yml b/config_sample.yml index 7534d96..9cabbe2 100644 --- a/config_sample.yml +++ b/config_sample.yml @@ -20,7 +20,8 @@ auth: # # restrict domain. (optional) # domain: -# - yourdomain.com +# - yourdomain.com # restrict by domain +# - example@gmail.com # or specific address # document root for static files htdocs: ./ diff --git a/httpd.go b/httpd.go index 0597813..ce27924 100644 --- a/httpd.go +++ b/httpd.go @@ -208,9 +208,15 @@ func restrictDomain(domain []string) martini.Handler { var user *User if len(domain) > 0 { for _, d := range domain { - if strings.HasSuffix(email, "@"+d) { - user = &User{email} - break + if strings.Contains(d, "@") { + if d == email { + user = &User{email} + } + } else { + if strings.HasSuffix(email, "@"+d) { + user = &User{email} + break + } } } } else {