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, name_model_as, numbered, #save, #save_and_notify!, #save_and_notify_changes!, #update_and_notify!, update_or_create!

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
  raise '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!
  raise 'Invalid Api Client' if Mumukit::Auth::Token.decode(token).uid != user.uid
end