mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +01:00
Fix ClusterCockpit/cc-frontend#31: Add user role to LDAP users
This commit is contained in:
parent
f82e78eaeb
commit
d67f5dd23b
@ -206,13 +206,13 @@ func (auth *Authentication) FetchUsers(viaLdap, notJustUser bool) ([]*User, erro
|
||||
q := sq.Select("username", "name", "email", "roles").From("user")
|
||||
if !viaLdap {
|
||||
if notJustUser {
|
||||
q = q.Where("ldap = 0 OR roles != '[\"user\"]'")
|
||||
q = q.Where("ldap = 0 OR (roles != '[\"user\"]' AND roles != '[]')")
|
||||
} else {
|
||||
q = q.Where("ldap = 0")
|
||||
}
|
||||
} else {
|
||||
if notJustUser {
|
||||
q = q.Where("ldap = 1 OR roles != '[\"user\"]'")
|
||||
q = q.Where("ldap = 1 OR (roles != '[\"user\"]' AND roles != '[]')")
|
||||
} else {
|
||||
q = q.Where("ldap = 1")
|
||||
}
|
||||
|
@ -149,9 +149,9 @@ func (auth *Authentication) SyncWithLDAP(deleteOldUsers bool) error {
|
||||
}
|
||||
} else if where == IN_LDAP {
|
||||
name := newnames[username]
|
||||
log.Infof("ldap-sync: add %#v (name: %#v, roles: [], ldap: true)", username, name)
|
||||
log.Infof("ldap-sync: add %#v (name: %#v, roles: [user], ldap: true)", username, name)
|
||||
if _, err := auth.db.Exec(`INSERT INTO user (username, ldap, name, roles) VALUES (?, ?, ?, ?)`,
|
||||
username, 1, name, "[]"); err != nil {
|
||||
username, 1, name, "[\""+RoleUser+"\"]"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user