Explorar el Código

models/login_source: add check for user for create/update on LDAP (#4405)

* Add check for user for create/update

* Update login_source.go

* Update login_source.go
Jon Lundy hace 7 años
padre
commit
1755025e7f
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      models/login_source.go

+ 10 - 0
models/login_source.go

@@ -327,6 +327,16 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR
 		IsActive:    true,
 		IsAdmin:     isAdmin,
 	}
+	
+	ok, err := IsUserExist(0, user.Name)
+	if err != nil {
+		return user, err
+	}
+	
+	if ok {
+		return user, UpdateUser(user)
+	}
+	
 	return user, CreateUser(user)
 }