Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions models/login_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion models/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (

var templates *template.Template

// InitMailRender initializes the macaron mail renderer
// InitMailRender initializes the mail renderer
func InitMailRender(tmpls *template.Template) {
templates = tmpls
}
Expand Down