-
Notifications
You must be signed in to change notification settings - Fork 0
Fix an admin bug on users route #228
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 %> | ||
|
|
@@ -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) %> | ||
|
||
| <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
|
||
| </div> | ||
|
|
||
There was a problem hiding this comment.
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 withTime.zone.now, consider parsing once into a local variable (preferably usingTime.zone.parse/Time.iso8601depending on the stored format) and reusing it for both comparisons and formatting.