Attempt #3 of ldap fixes

tokarchuk/v1.17
Gogs 10 years ago
parent d85366930c
commit fab038b175
  1. 7
      modules/auth/auth.go
  2. 10
      routers/repo/http.go

@ -108,19 +108,18 @@ func SignedInUser(req *http.Request, sess session.Store) (*models.User, bool) {
auths := strings.Fields(baHead) auths := strings.Fields(baHead)
if len(auths) == 2 && auths[0] == "Basic" { if len(auths) == 2 && auths[0] == "Basic" {
uname, passwd, _ := base.BasicAuthDecode(auths[1]) uname, passwd, _ := base.BasicAuthDecode(auths[1])
u, err := models.GetUserByName(uname)
u, err := models.UserSignIn(uname, passwd)
if err != nil { if err != nil {
if err != models.ErrUserNotExist { if err != models.ErrUserNotExist {
log.Error(4, "GetUserByName: %v", err) log.Error(4, "UserSignIn: %v", err)
} }
return nil, false return nil, false
} }
if u.ValidtePassword(passwd) {
return u, true return u, true
} }
} }
}
return nil, false return nil, false
} }

@ -105,10 +105,10 @@ func Http(ctx *middleware.Context) {
return return
} }
authUser, err = models.GetUserByName(authUsername) authUser, err := models.UserSignIn(authUsername, authPasswd)
if err != nil { if err != nil {
if err != models.ErrUserNotExist { if err != models.ErrUserNotExist {
ctx.Handle(500, "GetUserByName", err) ctx.Handle(500, "UserSignIn error: %v", err)
return return
} }
@ -128,12 +128,6 @@ func Http(ctx *middleware.Context) {
return return
} }
authUsername = authUser.Name authUsername = authUser.Name
} else {
// Check user's password when username is correctly presented.
if !authUser.ValidtePassword(authPasswd) {
ctx.Handle(401, "invalid password", nil)
return
}
} }
if !isPublicPull { if !isPublicPull {

Loading…
Cancel
Save