Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Split admin and regular users in system-admin. Allow delete user #980

Merged
merged 5 commits into from
Nov 5, 2020

Conversation

whaught
Copy link
Contributor

@whaught whaught commented Nov 5, 2020

Issue ##975

Proposed Changes

  • Creates a new users tab in system-admin
    • Keeps system-admin list and regular users separate
  • Allow system admin to delete a user
  • Searching and pagination

withsearch

Release Note

Show regular users across realms in system-admin. Allow deletion.

@google-cla google-cla bot added the cla: yes Auto: added by CLA bot when all committers have signed a CLA. label Nov 5, 2020
Copy link
Member

@sethvargo sethvargo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. I'd like us to avoid introducing a new term though. "super user" should be "system admin" everywhere, including routing, to avoid confusion.


var form FormData
err := controller.BindForm(w, r, &form)
email := project.TrimSpace(form.Email)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This trimming and validation should happen in the model via a BeforeSave, not the controller.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does also happen in BeforeSave, but FindUserByEmail needs the trim

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not trim in FindUserByEmail then?

pkg/controller/admin/users.go Outdated Show resolved Hide resolved
pkg/database/user.go Show resolved Hide resolved
var users []*User
if err := db.db.
Model(&User{}).
Where("admin IS FALSE").
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exclude admins?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two pages: Admin users and Users. The delete action deletes the user here, but the admin users delete button just de-privileges the user by removing the admin bit.
I'm considering merging things or moving actions to a sub-page together, but for now I'm trying to keep them separate

pkg/database/user.go Outdated Show resolved Hide resolved
whaught and others added 3 commits November 5, 2020 10:30
Co-authored-by: Seth Vargo <seth@sethvargo.com>
@sethvargo
Copy link
Member

/lgtm
/approve

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sethvargo, whaught

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit bbf05ff into google:main Nov 5, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2020
@whaught whaught deleted the list-users-in-admin branch November 6, 2020 21:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Auto: added by CLA bot when all committers have signed a CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants