Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6672 Allow some admins to set a generic username #4994

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

brianjaustin
Copy link
Member

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6672

Purpose

Allow superadmins and policy_and_abuse to set a generic username for users (even when banned). Because #4991 is already open, I have not added the subscript for "Ticket ID" as noted in the ticket.

Side question: do we want to update some of the copy/variables here to be more consistent? I observed login (has to stay), user name, and username in different spots...

@sarken
Copy link
Collaborator

sarken commented Dec 17, 2024

If you're up for changing copy in a whole bunch of places, I'm up for testing! We ultimately want to switch from "user name" to "username" but it's in soooo many places I didn't want to inflict that on anyone.

I think this covers all the references to this page so we could at least have some consistency in this area:

  • this change_username page, including error messages
  • the link in the /views/users/_edit_header_navigation.html.erb partial
  • the link in the /views/users/_edit_user_navigation.html.erb partial
  • the reference to this page on /app/views/pseuds/_pseuds_form.html.erb ("You cannot change the pseud that matches your user name. However, you can change your user name instead.")
  • the link in /app/views/preferences/index.html.erb

Copy link
Collaborator

@sarken sarken left a comment

Choose a reason for hiding this comment

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

Just a couple quick frontend suggestions since we were talking about text changes!

app/views/users/_admin_change_username.html.erb Outdated Show resolved Hide resolved
config/locales/models/en.yml Outdated Show resolved Hide resolved
app/views/users/_admin_change_username.html.erb Outdated Show resolved Hide resolved
Copy link
Contributor

@Bilka2 Bilka2 left a comment

Choose a reason for hiding this comment

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

Besides the comments I left, I think it would be good to have a feature test that goes through renaming a user as an admin. Just to make sure nothing gets missed because the specs test pretty close to the implementation itself.

.rubocop.yml Outdated Show resolved Hide resolved
app/controllers/pseuds_controller.rb Outdated Show resolved Hide resolved
app/controllers/pseuds_controller.rb Show resolved Hide resolved
app/controllers/users_controller.rb Outdated Show resolved Hide resolved
app/models/user.rb Outdated Show resolved Hide resolved
config/locales/views/en.yml Outdated Show resolved Hide resolved
end

it_behaves_like "an action only authorized admins can access", authorized_roles: %w[superadmin policy_and_abuse] do
let(:user) { create(:user, banned: true) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a banned user?

Copy link
Member Author

Choose a reason for hiding this comment

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

Non-exhaustive checking that users who cannot access this page themselves can be renamed by an admin

end

it "does not prevent changing the username" do
allow(existing_user).to receive(:justification_enabled?).and_return(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

What about ticket_number?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since https://github.com/otwcode/otwarchive/pull/4994/files#diff-a55bf747ae62cffdcdb15d898d6bde2ab06b44df40317d8c44330e1615b6c50fR133 already tests that, I disabled the ticket_number requirement here. I'd rather not turn it back on, because we have to mock quite a few things to make the Zoho validation happy

spec/models/user_spec.rb Show resolved Hide resolved
Copy link
Collaborator

@sarken sarken left a comment

Choose a reason for hiding this comment

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

I was reviewing in two tabs simultaneously so I could go back and forth between the views and the locales, so I'm sure this will be quality. If anything is confusing or contradictory, my bad, please yell!

app/controllers/pseuds_controller.rb Show resolved Hide resolved
@@ -564,11 +572,25 @@ def reindex_user_creations_after_rename
end

def add_renamed_at
return if User.current_user.is_a?(Admin)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with Brian here. Since we're already supposed to be ignoring the renamed_at when an admin goes to change a name, I think it makes sense that admin renames just ignore the renamed_at entirely.

However, we could add a separate admin_renamed_at column to the users table for general tracking purposes. That does feel like something that could be both useful and clarifying if you're looking at an audit or just a user in the database.

app/views/admin/admin_invitations/find.html.erb Outdated Show resolved Hide resolved
app/views/admin/admin_invitations/find.html.erb Outdated Show resolved Hide resolved
app/views/admin/admin_invitations/index.html.erb Outdated Show resolved Hide resolved
app/views/invitations/_user_invitations.html.erb Outdated Show resolved Hide resolved
app/views/users/_admin_change_username.html.erb Outdated Show resolved Hide resolved
config/locales/controllers/en.yml Outdated Show resolved Hide resolved
config/locales/devise/en.yml Show resolved Hide resolved
@github-actions github-actions bot added the Has Migrations Contains migrations and therefore needs special attention when deploying label Dec 30, 2024
@@ -1,29 +1,29 @@
<dl>
<dt>Sender</dt>
<dd><%= creator_link(invitation) %></dd>
<dd><%= creator_link(@invitation) %></dd>
Copy link
Member Author

Choose a reason for hiding this comment

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

I needed to make changes here to fix issues with how @invitation is referenced (locals versus just passing it in). For everyone's sanity, I'll do the rest of the erb lint fixes in #5000 since that has most of them already anyways

Copy link
Contributor

@Bilka2 Bilka2 left a comment

Choose a reason for hiding this comment

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

Thank you!

app/views/admin/admin_invitations/find.html.erb Outdated Show resolved Hide resolved
app/views/admin/admin_invitations/find.html.erb Outdated Show resolved Hide resolved
app/views/admin/admin_invitations/find.html.erb Outdated Show resolved Hide resolved
app/views/admin/admin_invitations/index.html.erb Outdated Show resolved Hide resolved
app/views/admin/admin_invitations/index.html.erb Outdated Show resolved Hide resolved
app/views/users/change_username.html.erb Outdated Show resolved Hide resolved
app/views/users/change_username.html.erb Show resolved Hide resolved
app/views/admin/admin_invitations/find.html.erb Outdated Show resolved Hide resolved
app/views/admin/admin_invitations/find.html.erb Outdated Show resolved Hide resolved
app/views/admin/admin_invitations/find.html.erb Outdated Show resolved Hide resolved
@sarken
Copy link
Collaborator

sarken commented Jan 6, 2025

(Sorry for all the comments! If it makes you feel any better, the review took me three days to finish. 😆)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Coder Has Actioned Review Has Migrations Contains migrations and therefore needs special attention when deploying
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants