gimmyxd/mentors4me-api

View on GitHub
app/utils/token_generator.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module TokenGenerator
  def generate_authentication_token!
    loop do
      self.auth_token = Devise.friendly_token
      self.auth_token_created_at = Time.zone.now
      break auth_token unless self.class.exists?(auth_token: auth_token)
    end
  end
end