Skip to content
Open
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion app/views/admin/users/_index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
<h5>ORCID Token</h5>
<% if user.orcid_token.blank? %>
Missing
<% elsif user.orcid_expires_at.nil? %>
No expiration
<% elsif DateTime.parse(user.orcid_expires_at) < Time.zone.now %>
Expired
<% else %>
Comment on lines +134 to 138
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

DateTime.parse(user.orcid_expires_at) is now being called in multiple branches (and again in the footer condition). To reduce repeated parsing and avoid type-mismatch surprises when comparing with Time.zone.now, consider parsing once into a local variable (preferably using Time.zone.parse/Time.iso8601 depending on the stored format) and reusing it for both comparisons and formatting.

Copilot uses AI. Check for mistakes.
Expand All @@ -141,7 +143,7 @@
<div class="panel-footer">
<span class="title pull-left"><%= link_to_if user.claims_count > 0, pluralize(user.claims_count, "Claim"), admin_claims_path(source: params[:source], state: params[:state], user_id: user.uid) %></span>
<div class="btn-toolbar">
<% if can?(:manage, user) && Time.zone.now < user.orcid_expires_at %>
<% if can?(:manage, user) && user.orcid_expires_at.present? && Time.zone.now < DateTime.parse(user.orcid_expires_at) %>
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

can?(:manage, user) is checked twice: the whole footer is already inside <% if can?(:manage, user) %>, so repeating the same authorization check in the nested condition adds noise and makes future edits easier to get wrong. You can simplify the inner conditional to only the ORCID expiry/token logic.

Copilot uses AI. Check for mistakes.
<div class="btn-group btn-group-sm pull-right">
<%= link_to 'delete token', admin_user_path(user.uid, user: { orcid_token: nil, orcid_expires_at: Time.zone.now }), { method: :put, remote: true, class: 'btn btn-sm btn-warning btn-fill' } %>
Comment on lines +146 to 148
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

The "delete token" button is now gated on user.orcid_expires_at.present?, which means admins can no longer delete tokens that exist but have a nil expiration (the UI even shows "No expiration" above). Consider changing the condition to allow deletion whenever a token is present, and only use the expiration timestamp to decide whether to label it expired (rather than hiding the action entirely).

Copilot uses AI. Check for mistakes.
</div>
Expand Down
Loading