mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Fix ldap loginname (#18789)
* Use email_address table to check user's email when login with email adress * Update services/auth/signin.go * Fix test * Fix test * Fix logging in with ldap username != loginname * Fix if user does not exist yet * Make more clear this is loginName * Fix formatting Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							1ab88da0e4
						
					
				
				
					commit
					0cc2675c44
				
			@@ -20,10 +20,14 @@ import (
 | 
			
		||||
// Authenticate queries if login/password is valid against the LDAP directory pool,
 | 
			
		||||
// and create a local user if success when enabled.
 | 
			
		||||
func (source *Source) Authenticate(user *user_model.User, userName, password string) (*user_model.User, error) {
 | 
			
		||||
	sr := source.SearchEntry(userName, password, source.authSource.Type == auth.DLDAP)
 | 
			
		||||
	loginName := userName
 | 
			
		||||
	if user != nil {
 | 
			
		||||
		loginName = user.LoginName
 | 
			
		||||
	}
 | 
			
		||||
	sr := source.SearchEntry(loginName, password, source.authSource.Type == auth.DLDAP)
 | 
			
		||||
	if sr == nil {
 | 
			
		||||
		// User not in LDAP, do nothing
 | 
			
		||||
		return nil, user_model.ErrUserNotExist{Name: userName}
 | 
			
		||||
		return nil, user_model.ErrUserNotExist{Name: loginName}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	isAttributeSSHPublicKeySet := len(strings.TrimSpace(source.AttributeSSHPublicKey)) > 0
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user