Module: AuctionFunCore::Business::TokenGenerator
- Defined in:
- lib/auction_fun_core/business/token_generator.rb
Overview
The TokenGenerator module is responsible for generating interaction tokens used in various parts of the AuctionFun application for authentication and verification purposes, particularly in interactions with system users.
Class Method Summary collapse
-
.generate_email_token(length = 20) ⇒ String
Generates a secure, URL-safe base64 token primarily used for email verification.
-
.generate_phone_token(length = 6) ⇒ String
Generates a numerical token used for phone verification processes.
Class Method Details
.generate_email_token(length = 20) ⇒ String
Generates a secure, URL-safe base64 token primarily used for email verification. This method modifies certain characters to avoid common readability issues.
17 18 19 20 |
# File 'lib/auction_fun_core/business/token_generator.rb', line 17 def self.generate_email_token(length = 20) rlength = (length * 3) / 4 SecureRandom.urlsafe_base64(rlength).tr("lIO0", "sxyz") end |
.generate_phone_token(length = 6) ⇒ String
Generates a numerical token used for phone verification processes. The token is zero-padded to ensure it meets the required length.
30 31 32 |
# File 'lib/auction_fun_core/business/token_generator.rb', line 30 def self.generate_phone_token(length = 6) rand(0o00000..999_999).to_s.rjust(length, "0") end |