Sha256: b6f4b116f88b668e48b90bc69bfcf08a5d97d95e0248391a76c29749c92b13db
Contents?: true
Size: 626 Bytes
Versions: 25
Compression:
Stored size: 626 Bytes
Contents
# frozen_string_literal: true require 'securerandom' module Apicasso # A model to abstract API access, with scope options, token generation, request limiting class Key < ApplicationRecord before_create :set_auth_token private # Method that generates `SecureRandom.uuid` as token until # an unique one has been acquired def set_auth_token loop do self.token = generate_auth_token break unless self.class.exists?(token: token) end end # RFC4122 style token def generate_auth_token SecureRandom.uuid.delete('-') end end end
Version data entries
25 entries across 25 versions & 1 rubygems