mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Record and show the last time users have logged in
This commit is contained in:
parent
950da89d76
commit
1936c90c95
4 changed files with 10 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ class LoginController < ApplicationController
|
|||
case request.method
|
||||
when 'POST'
|
||||
if @user = User.authenticate(params['user_login'], params['user_password'])
|
||||
@user.update_attribute(:last_login_at, Time.now)
|
||||
return handle_post_success
|
||||
else
|
||||
handle_post_failure
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
<th><%= t('users.total_projects') %></th>
|
||||
<th><%= t('users.total_notes') %></th>
|
||||
<th><%= User.human_attribute_name('created_at') %></th>
|
||||
<th><%= User.human_attribute_name('last_login_at') %></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<% for user in @users %>
|
||||
|
|
@ -28,6 +29,7 @@
|
|||
<td><%= h user.projects.size %></td>
|
||||
<td><%= h user.notes.size %></td>
|
||||
<td><%= format_date(user.created_at) %></td>
|
||||
<td><%= format_date(user.last_login_at) %></td>
|
||||
<td><%= !user.is_admin? ? remote_delete_user(user) : " ".html_safe %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
|||
5
db/migrate/20200810123316_add_lastlogin_to_user.rb
Normal file
5
db/migrate/20200810123316_add_lastlogin_to_user.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddLastloginToUser < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :last_login_at, :datetime
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_08_07_175610) do
|
||||
ActiveRecord::Schema.define(version: 2020_08_10_123316) do
|
||||
|
||||
create_table "attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
t.integer "todo_id"
|
||||
|
|
@ -223,6 +223,7 @@ ActiveRecord::Schema.define(version: 2020_08_07_175610) do
|
|||
t.string "email"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "last_login_at"
|
||||
t.index ["login"], name: "index_users_on_login"
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue