summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-03 00:53:35 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-03 00:53:35 +0200
commit751261c2ffdc90e93869192555ae0d5e4070ff79 (patch)
tree5023240ca3a10653fe560a259d0e46e6c6a7240f /app/models
parentf2f2b31832ec320889f2178e7e08838723961a14 (diff)
Display stale accounts in users#index
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 49c22584..adfdc564 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -10,6 +10,8 @@ class User < ApplicationRecord
10 include Authentication::ByPassword 10 include Authentication::ByPassword
11 11
12 ROLES = %w[redaktion admin alumni].freeze 12 ROLES = %w[redaktion admin alumni].freeze
13 STALE_AMBER_YEARS = 3
14 STALE_RED_YEARS = 10
13 15
14 # Validations 16 # Validations
15 validates_presence_of :login 17 validates_presence_of :login
@@ -243,6 +245,14 @@ class User < ApplicationRecord
243 true 245 true
244 end 246 end
245 247
248 def staleness_tier(now = Time.zone.now)
249 return nil if alumni?
250 return :never if last_login_at.nil?
251
252 return :red if last_login_at <= now - STALE_RED_YEARS.years
253 return :amber if roles.any? && last_login_at <= now - STALE_AMBER_YEARS.years
254 nil
255 end
246 private 256 private
247 257
248 def roles_are_known 258 def roles_are_known