Class: RestPack::Web::Rack::User
- Inherits:
-
Object
- Object
- RestPack::Web::Rack::User
- Defined in:
- lib/restpack_web/rack/user.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(app) ⇒ User
Returns a new instance of User.
6 7 8 |
# File 'lib/restpack_web/rack/user.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/restpack_web/rack/user.rb', line 10 def call(env) session = env["restpack.session"] user_id = session[:user_id] account_id = session[:account_id] if user_id && account_id response = Commands::Users::User::Get.run({ id: user_id, application_id: env['restpack'][:application_id] }) raise "Error getting user" unless response.success? env['restpack'][:user] = response.result[:users][0] response = Commands::Accounts::Account::Get.run({ id: account_id, application_id: env['restpack'][:application_id] }) raise "Error getting account" unless response.success? env['restpack'][:account] = response.result[:accounts][0] end @app.call(env) end |