Skip to content

Commit e39a5f6

Browse files
committed
feat: Add lastLoginAt attribute and update_last_login method to User model
1 parent 60fa879 commit e39a5f6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • lib/ontologies_linked_data/models/users

lib/ontologies_linked_data/models/users/user.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class User < LinkedData::Models::Base
2828
attribute :githubId, enforce: [:unique]
2929
attribute :orcidId, enforce: [:unique]
3030
attribute :created, enforce: [:date_time], :default => lambda { |record| DateTime.now }
31+
attribute :lastLoginAt, enforce: [:date_time], :default => lambda { |record| DateTime.now }
3132
attribute :passwordHash, enforce: [:existence]
3233
attribute :apikey, enforce: [:unique], :default => lambda {|x| SecureRandom.uuid}
3334
attribute :subscription, enforce: [:list, :subscription]
@@ -81,6 +82,11 @@ def initialize(attributes = {})
8182
self
8283
end
8384

85+
def update_last_login
86+
self.lastLoginAt = DateTime.now
87+
self.save
88+
end
89+
8490
def save(*args)
8591
# Reset ontology cache if user changes their custom set
8692
if LinkedData.settings.enable_http_cache && self.modified_attributes.include?(:customOntology)

0 commit comments

Comments
 (0)