diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1af6a14b..560a01ab 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -58,6 +58,8 @@ class ApplicationController < ActionController::Base private def user_not_authorized + logger.error { "User not authorized: #{user_signed_in? ? current_user.inspect : 'unlogged user'}" } + render json: { error: t('errors.unauthorized') }, status: :unauthorized diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb index c1344a90..914a11f5 100644 --- a/app/controllers/tenants_controller.rb +++ b/app/controllers/tenants_controller.rb @@ -47,9 +47,13 @@ class TenantsController < ApplicationController CreateWelcomeEntitiesWorkflow.new().run + logger.info { "New tenant registration: #{Current.tenant.inspect}" } + render json: @tenant, status: :created rescue ActiveRecord::RecordInvalid => exception + logger.error { "Error in tenant registration: #{exception}" } + render json: { error: exception }, status: :unprocessable_entity end end diff --git a/app/workflows/o_auth_exchange_auth_code_for_profile_workflow.rb b/app/workflows/o_auth_exchange_auth_code_for_profile_workflow.rb index b25957c2..7392d212 100644 --- a/app/workflows/o_auth_exchange_auth_code_for_profile_workflow.rb +++ b/app/workflows/o_auth_exchange_auth_code_for_profile_workflow.rb @@ -49,7 +49,8 @@ class OAuthExchangeAuthCodeForProfileWorkflow return profile_response rescue => error - print(error) + logger.error { "Error in OAuthExchangeAuthCodeForProfileWorkflow: #{error}, o_auth: #{@o_auth.inspect}" } + return nil end end diff --git a/app/workflows/o_auth_sign_in_user_workflow.rb b/app/workflows/o_auth_sign_in_user_workflow.rb index 4a907692..683cc386 100644 --- a/app/workflows/o_auth_sign_in_user_workflow.rb +++ b/app/workflows/o_auth_sign_in_user_workflow.rb @@ -52,7 +52,7 @@ class OAuthSignInUserWorkflow return user rescue => error - print(error) + logger.error { "Error in OAuthSignInUserWorkflow: #{error}, o_auth: #{@o_auth.inspect}" } return nil end end diff --git a/config/environments/production.rb b/config/environments/production.rb index ba33a0c2..be4235e4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -51,7 +51,7 @@ Rails.application.configure do config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [ :request_id, :original_url, :remote_ip ] # Use a different cache store in production. # config.cache_store = :mem_cache_store