Skip to content
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
6 changes: 6 additions & 0 deletions app/assets/stylesheets/components/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
margin-bottom: var(--spacing-8);
}

.settings-page .settings-page-count {
font-weight: var(--font-weight-regular);
color: var(--color-text-muted);
margin-left: var(--spacing-2);
}

.settings-section {
padding: var(--spacing-6) 0;
border-bottom: var(--border-width) solid var(--color-border);
Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def active_admin_section
end

def index
@users_total_count = User.active.count
@users = User.active
.includes(person: [ :default_alias, :aliases ])
.order(created_at: :desc)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def google_oauth2

reset_session
session[:user_id] = identity.user_id
identity.user.update_columns(last_login_at: Time.current)
redirect_to root_path, notice: "Signed in with Google"
rescue => e
Rails.logger.error("OIDC error: #{e.class}: #{e.message}")
Expand Down
1 change: 1 addition & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def create
else
reset_session
session[:user_id] = user.id
user.update_columns(last_login_at: Time.current)
redirect_to root_path, notice: "Signed in successfully"
end
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/verifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def handle_register(token)

reset_session
session[:user_id] = user.id
user.update_columns(last_login_at: Time.current)
redirect_to root_path, notice: "Registration complete. You are signed in."
end

Expand Down
7 changes: 6 additions & 1 deletion app/views/admin/users/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
- content_for :title, "Admin — Users"

.settings-page
h1 Users
h1
| Users
- if @users_total_count
span.settings-page-count = "(#{@users_total_count})"

.email-table-wrap
table.email-table
Expand All @@ -11,6 +14,7 @@
th Emails
th Admin
th Created
th Last login
th Actions
tbody
- @users.each do |user|
Expand Down Expand Up @@ -41,5 +45,6 @@
= button_to toggle_admin_admin_user_path(user), method: :post, class: "button-secondary button-small", data: { turbo_confirm: "#{user.admin? ? 'Remove' : 'Grant'} admin privileges for #{user.username}?" } do
= user.admin? ? "Remove admin" : "Make admin"
td = user.created_at.strftime('%Y-%m-%d')
td = user.last_login_at ? smart_time_display(user.last_login_at) : "—"
td
= link_to "Add email", new_email_admin_user_path(user), class: "button-secondary button-small"
5 changes: 5 additions & 0 deletions db/migrate/20260218120000_add_last_login_at_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddLastLoginAtToUsers < ActiveRecord::Migration[7.1]
def change
add_column :users, :last_login_at, :datetime
end
end