summaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 815a6d343..f7a9c33bd 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -417,6 +417,20 @@ class User < Principal
token.value
end
+ def delete_session_token(value)
+ Token.where(:user_id => id, :action => 'session', :value => value).delete_all
+ end
+
+ # Generates a new autologin token and returns its value
+ def generate_autologin_token
+ token = Token.create!(:user_id => id, :action => 'autologin')
+ token.value
+ end
+
+ def delete_autologin_token(value)
+ Token.where(:user_id => id, :action => 'autologin', :value => value).delete_all
+ end
+
# Returns true if token is a valid session token for the user whose id is user_id
def self.verify_session_token(user_id, token)
return false if user_id.blank? || token.blank?