mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 05:19:05 +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")
|
q := sq.Select("username", "name", "email", "roles").From("user")
|
||||||
if !viaLdap {
|
if !viaLdap {
|
||||||
if notJustUser {
|
if notJustUser {
|
||||||
q = q.Where("ldap = 0 OR roles != '[\"user\"]'")
|
q = q.Where("ldap = 0 OR (roles != '[\"user\"]' AND roles != '[]')")
|
||||||
} else {
|
} else {
|
||||||
q = q.Where("ldap = 0")
|
q = q.Where("ldap = 0")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if notJustUser {
|
if notJustUser {
|
||||||
q = q.Where("ldap = 1 OR roles != '[\"user\"]'")
|
q = q.Where("ldap = 1 OR (roles != '[\"user\"]' AND roles != '[]')")
|
||||||
} else {
|
} else {
|
||||||
q = q.Where("ldap = 1")
|
q = q.Where("ldap = 1")
|
||||||
}
|
}
|
||||||
|
@ -149,9 +149,9 @@ func (auth *Authentication) SyncWithLDAP(deleteOldUsers bool) error {
|
|||||||
}
|
}
|
||||||
} else if where == IN_LDAP {
|
} else if where == IN_LDAP {
|
||||||
name := newnames[username]
|
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 (?, ?, ?, ?)`,
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user