summaryrefslogtreecommitdiffstats
path: root/models/login_source.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/login_source.go')
-rw-r--r--models/login_source.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/models/login_source.go b/models/login_source.go
index 69602b8b16..9b8173b84d 100644
--- a/models/login_source.go
+++ b/models/login_source.go
@@ -11,10 +11,10 @@ import (
"fmt"
"net/smtp"
"net/textproto"
+ "regexp"
"strings"
"github.com/Unknwon/com"
- "github.com/go-macaron/binding"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
@@ -384,6 +384,10 @@ func composeFullName(firstname, surname, username string) string {
}
}
+var (
+ alphaDashDotPattern = regexp.MustCompile("[^\\w-\\.]")
+)
+
// LoginViaLDAP queries if login/password is valid against the LDAP directory pool,
// and create a local user if success when enabled.
func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoRegister bool) (*User, error) {
@@ -408,7 +412,7 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR
sr.Username = login
}
// Validate username make sure it satisfies requirement.
- if binding.AlphaDashDotPattern.MatchString(sr.Username) {
+ if alphaDashDotPattern.MatchString(sr.Username) {
return nil, fmt.Errorf("Invalid pattern for attribute 'username' [%s]: must be valid alpha or numeric or dash(-_) or dot characters", sr.Username)
}