about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/invite.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/invite.rb b/app/models/invite.rb
index ceca04686..7626f4cfa 100644
--- a/app/models/invite.rb
+++ b/app/models/invite.rb
@@ -27,13 +27,17 @@ class Invite < ApplicationRecord
   end
 
   def valid_for_use?
-    (max_uses.nil? || uses < max_uses) && (expires_at.nil? || expires_at >= Time.now.utc)
+    (max_uses.nil? || uses < max_uses) && !expired?
   end
 
   def expire!
     touch(:expires_at)
   end
 
+  def expired?
+    !expires_at.nil? && expires_at < Time.now.utc
+  end
+
   private
 
   def set_code