diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b360c2f92..de1b82025 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,13 +35,12 @@ def set_jsonp_format end def detect_crawler - #### Crawlers shound't be making queires + #### Crawlers shouldn't be making queires if request.is_crawler? && params[:query].present? render json: {}, status: :not_found end end - def set_consumer_header if current_user response.headers['X-Credential-Username'] = current_user.uid diff --git a/app/models/concerns/authenticable.rb b/app/models/concerns/authenticable.rb index fc734676b..ae2de4b65 100644 --- a/app/models/concerns/authenticable.rb +++ b/app/models/concerns/authenticable.rb @@ -163,6 +163,11 @@ def get_payload(uid: nil, user: nil, password: nil) "client_id" => uid, "password" => password }) + elsif user.role_name == "ROLE_CONSORTIUM" + payload.merge!({ + "provider_id" => uid, + "consortium_id" => uid + }) elsif uid != "admin" payload.merge!({ "provider_id" => uid diff --git a/spec/concerns/authenticable_spec.rb b/spec/concerns/authenticable_spec.rb index b5fe758d7..bf89e0d99 100644 --- a/spec/concerns/authenticable_spec.rb +++ b/spec/concerns/authenticable_spec.rb @@ -260,6 +260,11 @@ subject = create(:provider, symbol: "ADMIN", role_name: "ROLE_ADMIN", password_input: "12345") expect(subject.decode_auth_param(username: subject.symbol, password: "12345")).to eq("uid"=>subject.symbol.downcase, "name"=>subject.name, "email"=>subject.system_email, "role_id"=>"staff_admin") end + + it "consortium" do + subject = create(:provider, role_name: "ROLE_CONSORTIUM", password_input: "12345") + expect(subject.decode_auth_param(username: subject.symbol, password: "12345")).to eq("uid"=>subject.symbol.downcase, "name"=>subject.name, "email"=>subject.system_email, "role_id"=>"provider_admin", "provider_id"=>subject.symbol.downcase, "consortium_id"=>subject.symbol.downcase) + end end end