Class: TentD::API::Apps::GetActualId

Inherits:
Middleware show all
Defined in:
lib/tentd/api/apps.rb

Instance Method Summary collapse

Methods inherited from Middleware

#call, #initialize

Methods included from TentD::API::Authorizable

#authorize_env!, #authorize_env?

Constructor Details

This class inherits a constructor from TentD::API::Middleware

Instance Method Details

#action(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tentd/api/apps.rb', line 7

def action(env)
  if env.params.app_id
    if app = Model::App.first(:public_id => env.params.app_id)
      env.params.app_id = app.id
    else
      env.params.app_id = nil
    end
  end

  if env.params.auth_id
    if app_auth = Model::AppAuthorization.first(:public_id => env.params.auth_id)
      env.params.auth_id = app_auth.id
    else
      env.params.auth_id = nil
    end
  end

  env
end