aboutsummaryrefslogtreecommitdiffstats
path: root/models/login.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-12-05 18:08:09 -0500
committerUnknwon <joe2010xtmf@163.com>2014-12-05 18:08:09 -0500
commit0b785ad96785f62166eb88e7f1415c918e102e71 (patch)
treea9b5fbb1227d4e08fa0428855343a694e8e24be7 /models/login.go
parent069486d169d7adac902a310e10b6580857735880 (diff)
downloadgitea-0b785ad96785f62166eb88e7f1415c918e102e71.tar.gz
gitea-0b785ad96785f62166eb88e7f1415c918e102e71.zip
work on #672
Diffstat (limited to 'models/login.go')
-rw-r--r--models/login.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/models/login.go b/models/login.go
index 87dbbacc76..3986353192 100644
--- a/models/login.go
+++ b/models/login.go
@@ -18,6 +18,7 @@ import (
"github.com/gogits/gogs/modules/auth/ldap"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/uuid"
)
type LoginType int
@@ -228,30 +229,32 @@ func UserSignIn(uname, passwd string) (*User, error) {
// Query if name/passwd can login against the LDAP direcotry pool
// Create a local user if success
// Return the same LoginUserPlain semantic
+// FIXME: https://github.com/gogits/gogs/issues/672
func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAPConfig, autoRegister bool) (*User, error) {
mail, logged := cfg.Ldapsource.SearchEntry(name, passwd)
if !logged {
- // user not in LDAP, do nothing
+ // User not in LDAP, do nothing
return nil, ErrUserNotExist
}
if !autoRegister {
return u, nil
}
- // fake a local user creation
+ // Fallback.
+ if len(mail) == 0 {
+ mail = uuid.NewV4().String() + "@localhost"
+ }
+
u = &User{
- LowerName: strings.ToLower(name),
- Name: strings.ToLower(name),
+ Name: name,
LoginType: LDAP,
LoginSource: sourceId,
LoginName: name,
- IsActive: true,
Passwd: passwd,
Email: mail,
+ IsActive: true,
}
-
- err := CreateUser(u)
- return u, err
+ return u, CreateUser(u)
}
type loginAuth struct {