Skip to content

Instantly share code, notes, and snippets.

@truongnmt
Created January 4, 2022 23:29
Show Gist options
  • Save truongnmt/4e3e0c21af2b8122e04176a7dbb63eaa to your computer and use it in GitHub Desktop.
Save truongnmt/4e3e0c21af2b8122e04176a7dbb63eaa to your computer and use it in GitHub Desktop.
app/models/user.rb
class User < ApplicationRecord
devise :database_authenticatable, :recoverable, :rememberable
def authenticatable_salt
return super unless session_token
"#{super}#{session_token}"
end
def invalidate_all_sessions!
update_attribute(:session_token, SecureRandom.hex)
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment