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

aggregate_of, all_except, defaults, #delete, #destroy!, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, #update_and_notify!, update_or_create!, whitelist_attributes

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