GRN2-174: Added 404 if user does not exist (#609)

* Added 404 if user does not exist

* Differentiated between 404 and 500

* Rspec fixes
This commit is contained in:
farhatahmad
2019-07-09 11:00:33 -04:00
committed by Jesus Federico
parent e4f50026f1
commit 5d4bd1b851
4 changed files with 54 additions and 8 deletions

View File

@ -131,10 +131,21 @@ class ApplicationController < ActionController::Base
end
def set_user_domain
@user_domain = if Rails.env.test? || !Rails.configuration.loadbalanced_configuration
"greenlight"
if Rails.env.test? || !Rails.configuration.loadbalanced_configuration
@user_domain = "greenlight"
else
parse_user_domain(request.host)
@user_domain = parse_user_domain(request.host)
# Checks to see if the user exists
begin
retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
rescue => e
if e.message.eql? "No user with that id exists"
render "errors/not_found", locals: { user_not_found: true }
else
render "errors/internal_error"
end
end
end
end
helper_method :set_user_domain