module RedTokenAuth::Authentication

Public Instance Methods

authenticate_token(token) click to toggle source
# File lib/red_token_auth/authentication.rb, line 6
def authenticate_token(token)
  BCrypt::Password.new(authentication_token) == token
end
create_new_authentication_token() click to toggle source
# File lib/red_token_auth/authentication.rb, line 10
def create_new_authentication_token
  token        = SecureRandom.urlsafe_base64(nil, true)
  token_hash   = BCrypt::Password.create(token)

  self.authentication_token = token_hash

  save!

  {
    "access-token" => token,
    "uid"          => email,
    "token-type"   => "Bearer"
  }
end