mirror of
1
Fork 0

Remove macaron dependent on models (#6940)

This commit is contained in:
Lunny Xiao 2019-05-14 21:52:18 +08:00 committed by techknowlogick
parent 8b36f01f45
commit 24a536d145
2 changed files with 7 additions and 3 deletions

View File

@ -11,10 +11,10 @@ import (
"fmt" "fmt"
"net/smtp" "net/smtp"
"net/textproto" "net/textproto"
"regexp"
"strings" "strings"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/go-macaron/binding"
"github.com/go-xorm/core" "github.com/go-xorm/core"
"github.com/go-xorm/xorm" "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, // LoginViaLDAP queries if login/password is valid against the LDAP directory pool,
// and create a local user if success when enabled. // and create a local user if success when enabled.
func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoRegister bool) (*User, error) { 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 sr.Username = login
} }
// Validate username make sure it satisfies requirement. // 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) return nil, fmt.Errorf("Invalid pattern for attribute 'username' [%s]: must be valid alpha or numeric or dash(-_) or dot characters", sr.Username)
} }

View File

@ -33,7 +33,7 @@ const (
var templates *template.Template var templates *template.Template
// InitMailRender initializes the macaron mail renderer // InitMailRender initializes the mail renderer
func InitMailRender(tmpls *template.Template) { func InitMailRender(tmpls *template.Template) {
templates = tmpls templates = tmpls
} }