Skip to content

Commit

Permalink
Record last login timestamp on users during when logging in
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Feb 7, 2018
1 parent 7bb6f4c commit 7c9c54b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def create
flash[:notice] = nil
session[:user_id] = identity.user.id
end


identity.user.update_columns(last_login_at: Time.current)
identity.user.update_repo_permissions_async
login_destination = pre_login_destination

Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20180207110908_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[5.0]
def change
add_column :users, :last_login_at, :datetime
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20171109154509) do
ActiveRecord::Schema.define(version: 20180207110908) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -292,6 +292,7 @@
t.datetime "last_synced_at"
t.boolean "emails_enabled", :default=>true
t.boolean "optin", :default=>false
t.datetime "last_login_at"
end

create_table "versions", force: :cascade do |t|
Expand Down

0 comments on commit 7c9c54b

Please sign in to comment.