diff --git a/app/controllers/api/v0/base_controller.rb b/app/controllers/api/v0/base_controller.rb index 5d80b5b..795d988 100644 --- a/app/controllers/api/v0/base_controller.rb +++ b/app/controllers/api/v0/base_controller.rb @@ -103,9 +103,7 @@ def authenticate_token authenticate_with_http_token do |token, options| @token = token - logger.debug "whats the token? #{token}" - @user = User.find_by api_token: token - logger.debug "did we even find a guy? #{@user}" + @user = User.find_by(api_token: token) !@user.nil? end end @@ -113,7 +111,7 @@ def render_bad_credentials self.headers['WWW-Authenticate'] = "Token realm=\"\"" - render json: '"Bad credentials"', status: 401 + render json: I18n.t("api.bad_credentials"), status: 401 end def has_auth (auth_type) diff --git a/config/locales/en.yml b/config/locales/en.yml index f2c4dcc..de6ca30 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -899,4 +899,13 @@ unlock: 'Unlock my account' waiting_for_confirmation: "Currently waiting confirmation for: " resend_unlock: "Resend unlock instructions" + api: + bad_credentials: '{"Error":"Bad credentials"}' + org_dosent_exist: '{"Error":"Organisation does not exist"}' + org_not_funder: '{"Error":"Organisation specified is not a funder"}' + org_multiple_templates: '{"Error":"Organisation has more than one template and template name unspecified or invalid"}' + no_auth_for_endpoint: '{"Error":"You do not have authorisation to view this endpoint"}' + bad_resource: '{"Error":"You do not have authorisation to view this resource"}' + +