Created
June 9, 2018 23:28
-
-
Save jordanhudgens/afa5bbd136674c65f1873d97cbc42c64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AuthTokenConcern | |
extend ActiveSupport::Concern | |
included do | |
before_action :unique_auth_token | |
end | |
def unique_auth_token | |
unique_auth = false | |
while unique_auth == false | |
auth_key = SecureRandom.base64.tr('+/=', 'Qrt') | |
if !User.all.where(auth_token: auth_key).any? | |
unique_auth = true | |
return auth_key | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment