Module: RailsOtp
- Defined in:
- lib/rails_otp.rb,
lib/rails_otp/otp.rb,
lib/rails_otp/exotel.rb,
lib/rails_otp/version.rb,
lib/rails_otp/configuration.rb,
lib/generators/rails_otp/migration_generator.rb
Defined Under Namespace
Classes: Configuration, Exotel, MigrationGenerator
Constant Summary
collapse
- VERSION =
"1.1.0"
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
8
9
10
|
# File 'lib/rails_otp.rb', line 8
def configuration
@configuration
end
|
Class Method Details
19
20
21
|
# File 'lib/rails_otp.rb', line 19
def self.configure
yield(configuration)
end
|
.reset ⇒ Object
15
16
17
|
# File 'lib/rails_otp.rb', line 15
def self.reset
@configuration = Configuration.new
end
|
Instance Method Details
#generate_otp ⇒ Object
4
5
6
7
8
9
|
# File 'lib/rails_otp/otp.rb', line 4
def generate_otp
self.verified_status = false
self.otp_expiry_time = RailsOtp::configuration.otp_expiry_time self.otp_code = SecureRandom.hex(4)
end
|
#generate_otp! ⇒ Object
11
12
13
14
|
# File 'lib/rails_otp/otp.rb', line 11
def generate_otp!
generate_otp
save
end
|
#regenerate_otp ⇒ Object
20
21
22
|
# File 'lib/rails_otp/otp.rb', line 20
def regenerate_otp
generate_otp
end
|
#regenerate_otp! ⇒ Object
24
25
26
27
|
# File 'lib/rails_otp/otp.rb', line 24
def regenerate_otp!
regenerate_otp
save
end
|
#verify_otp(otp) ⇒ Object
16
17
18
|
# File 'lib/rails_otp/otp.rb', line 16
def verify_otp(otp)
otp_code_valid?(otp) && code_not_expired
end
|