Module: Users::PhoneAuthenticate
- Included in:
- User
- Defined in:
- lib/users/phone_authenticate.rb
Overview
This module provides methods for sending and verifying OTPs (One-Time Passwords) via phone numbers. It includes methods to send an OTP to a user’s phone number and to authenticate the user by verifying the OTP.
Instance Method Summary collapse
-
#authenticate_by_phone(otp) ⇒ User, false
This method authenticates the user by verifying the provided OTP.
-
#send_otp(phone_number) ⇒ UserVerification
This method sends an OTP to the specified phone number.
Instance Method Details
#authenticate_by_phone(otp) ⇒ User, false
This method authenticates the user by verifying the provided OTP. It uses the Otp::Verify service to check if the OTP is valid.
17 18 19 20 21 22 23 24 |
# File 'lib/users/phone_authenticate.rb', line 17 def authenticate_by_phone(otp) if Otp::Verify.new(self, otp).authenticate # @type [User] self else false end end |
#send_otp(phone_number) ⇒ UserVerification
This method sends an OTP to the specified phone number. It uses the Otp::Send service to handle the OTP sending process.
9 10 11 |
# File 'lib/users/phone_authenticate.rb', line 9 def send_otp(phone_number) Otp::Send.new(self, phone_number).call end |