Module: CzAuth::RequiresAuthentication

Extended by:
ActiveSupport::Concern
Defined in:
lib/cz_auth/requires_authentication.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

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