Module: CzAuth::RequiresAuthentication
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cz_auth/requires_authentication.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#generate_token(column) ⇒ Object
Generate a token for the specified field.
-
#generate_token!(column) ⇒ Object
Generate a token for the specified field, and save.
-
#session_length ⇒ Object
Set the default length of the session Override to set different value Default: 2.weeks.
Instance Method Details
#generate_token(column) ⇒ Object
Generate a token for the specified field
15 16 17 18 19 |
# File 'lib/cz_auth/requires_authentication.rb', line 15 def generate_token(column) begin self[column] = SecureRandom.uuid end while self.class.exists?(column => self[column]) end |
#generate_token!(column) ⇒ Object
Generate a token for the specified field, and save
22 23 24 25 |
# File 'lib/cz_auth/requires_authentication.rb', line 22 def generate_token!(column) generate_token(column) save end |
#session_length ⇒ Object
Set the default length of the session Override to set different value Default: 2.weeks
30 31 32 |
# File 'lib/cz_auth/requires_authentication.rb', line 30 def session_length 2.weeks end |