Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/server/assets/admin/users/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@
<tbody>
{{range $users}}
<tr>
<td>{{.Name}}</td>
<td>
{{.Name}}
{{if .SystemAdmin}}
<span class="ml-1 badge badge-pill badge-primary">System admin</span>
{{end}}
{{if .IsRealmAdmin}}
<span class="ml-1 badge badge-pill badge-secondary">Realm admin</span>
{{end}}
</td>
<td>{{.Email}}</td>
<td class="text-center">
{{- /* cannot delete yourself */ -}}
Expand Down
5 changes: 4 additions & 1 deletion pkg/database/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func (u *User) CanViewRealm(realmID uint) bool {
return false
}

func (u *User) IsRealmAdmin() bool {
return len(u.AdminRealms) > 0
}

func (u *User) CanAdminRealm(realmID uint) bool {
for _, r := range u.AdminRealms {
if r.ID == realmID {
Expand Down Expand Up @@ -230,7 +234,6 @@ func (u *User) Stats(db *Database, realmID uint, start, stop time.Time) ([]*User
func (db *Database) ListUsers(p *pagination.PageParams, q string) ([]*User, *pagination.Paginator, error) {
var users []*User
query := db.db.Model(&User{}).
Where("system_admin IS FALSE").
Order("LOWER(name) ASC")

q = project.TrimSpace(q)
Expand Down