|
|
|
@ -20,9 +20,9 @@ import ( |
|
|
|
|
"github.com/go-xorm/xorm" |
|
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/auth/ldap" |
|
|
|
|
"code.gitea.io/gitea/modules/auth/oauth2" |
|
|
|
|
"code.gitea.io/gitea/modules/auth/pam" |
|
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
|
"code.gitea.io/gitea/modules/auth/oauth2" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// LoginType represents an login type.
|
|
|
|
@ -498,7 +498,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC |
|
|
|
|
idx := strings.Index(login, "@") |
|
|
|
|
if idx == -1 { |
|
|
|
|
return nil, ErrUserNotExist{0, login, 0} |
|
|
|
|
} else if !com.IsSliceContainsStr(strings.Split(cfg.AllowedDomains, ","), login[idx + 1:]) { |
|
|
|
|
} else if !com.IsSliceContainsStr(strings.Split(cfg.AllowedDomains, ","), login[idx+1:]) { |
|
|
|
|
return nil, ErrUserNotExist{0, login, 0} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -598,7 +598,7 @@ type OAuth2Provider struct { |
|
|
|
|
// key is used to map the OAuth2Provider with the goth provider type (also in LoginSource.OAuth2Config.Provider)
|
|
|
|
|
// value is used to store display data
|
|
|
|
|
var OAuth2Providers = map[string]OAuth2Provider{ |
|
|
|
|
"github": {Name: "github", DisplayName:"GitHub", Image: "/img/github.png"}, |
|
|
|
|
"github": {Name: "github", DisplayName: "GitHub", Image: "/img/github.png"}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ExternalUserLogin attempts a login using external source types.
|
|
|
|
@ -624,6 +624,16 @@ func UserSignIn(username, password string) (*User, error) { |
|
|
|
|
var user *User |
|
|
|
|
if strings.Contains(username, "@") { |
|
|
|
|
user = &User{Email: strings.ToLower(strings.TrimSpace(username))} |
|
|
|
|
// check same email
|
|
|
|
|
cnt, err := x.Count(user) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
if cnt > 1 { |
|
|
|
|
return nil, ErrEmailAlreadyUsed{ |
|
|
|
|
Email: user.Email, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
user = &User{LowerName: strings.ToLower(strings.TrimSpace(username))} |
|
|
|
|
} |
|
|
|
|