Class: ApiClient

Inherits:
ApplicationRecord show all
Defined in:
app/models/api_client.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

active_between, aggregate_of, all_except, defaults, #delete, #destroy!, enum_prefixed_translations_for, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, teaser_on, #update_and_notify!, update_or_create!, whitelist_attributes, with_pg_retry, with_temporary_token

Methods included from WithPgLock

#with_pg_lock

Class Method Details

.verify_token!(token) ⇒ Object



15
16
17
18
19
# File 'app/models/api_client.rb', line 15

def self.verify_token!(token)
  client = find_by token: token
  invalid_token! 'No Api Client found for Token' unless client
  client.verify!
end

Instance Method Details

#verify!Object



11
12
13
# File 'app/models/api_client.rb', line 11

def verify!
  self.class.invalid_token! 'Invalid Api Client' if Mumukit::Auth::Token.decode(token).uid != user.uid
end