forked from External/greenlight
Add check to make sure ldap username isn't blank (#1252)
Co-authored-by: Jesus Federico <jesus@123it.ca>
This commit is contained in:
parent
da82867abe
commit
7738499978
|
@ -139,7 +139,9 @@ class SessionsController < ApplicationController
|
|||
ldap_config[:base] = ENV['LDAP_BASE']
|
||||
ldap_config[:uid] = ENV['LDAP_UID']
|
||||
|
||||
return redirect_to(ldap_signin_path, alert: I18n.t("invalid_credentials")) unless session_params[:password].present?
|
||||
if params[:session][:username].blank? || session_params[:password].blank?
|
||||
return redirect_to(ldap_signin_path, alert: I18n.t("invalid_credentials"))
|
||||
end
|
||||
|
||||
result = send_ldap_request(params[:session], ldap_config)
|
||||
|
||||
|
|
|
@ -522,7 +522,7 @@ describe SessionsController, type: :controller do
|
|||
|
||||
post :ldap, params: {
|
||||
session: {
|
||||
user: "test",
|
||||
username: "test",
|
||||
password: 'password',
|
||||
},
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ describe SessionsController, type: :controller do
|
|||
|
||||
post :ldap, params: {
|
||||
session: {
|
||||
user: "test",
|
||||
username: "test",
|
||||
password: 'password',
|
||||
},
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ describe SessionsController, type: :controller do
|
|||
|
||||
post :ldap, params: {
|
||||
session: {
|
||||
user: "test",
|
||||
username: "test",
|
||||
password: 'password',
|
||||
},
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ describe SessionsController, type: :controller do
|
|||
|
||||
post :ldap, params: {
|
||||
session: {
|
||||
user: "test",
|
||||
username: "test",
|
||||
password: 'passwor',
|
||||
},
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ describe SessionsController, type: :controller do
|
|||
|
||||
post :ldap, params: {
|
||||
session: {
|
||||
user: "test",
|
||||
username: "test",
|
||||
password: '',
|
||||
},
|
||||
}
|
||||
|
@ -605,5 +605,19 @@ describe SessionsController, type: :controller do
|
|||
expect(response).to redirect_to(ldap_signin_path)
|
||||
expect(flash[:alert]).to eq(I18n.t("invalid_credentials"))
|
||||
end
|
||||
|
||||
it "redirects to signin if no username provided" do
|
||||
allow_any_instance_of(Net::LDAP).to receive(:bind_as).and_return(false)
|
||||
|
||||
post :ldap, params: {
|
||||
session: {
|
||||
username: "",
|
||||
password: 'test',
|
||||
},
|
||||
}
|
||||
|
||||
expect(response).to redirect_to(ldap_signin_path)
|
||||
expect(flash[:alert]).to eq(I18n.t("invalid_credentials"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue