Commit bd99458a authored by Sean McGivern's avatar Sean McGivern

Merge branch 'feature/log-provider' into 'master'

[EE Backport] Update log audit event in omniauth_callbacks_controller.rb

See merge request !13339
parents f9c6ff75 aa25db89
...@@ -34,12 +34,11 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -34,12 +34,11 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
if @user.two_factor_enabled? if @user.two_factor_enabled?
prompt_for_two_factor(@user) prompt_for_two_factor(@user)
else else
log_audit_event(@user, with: :ldap) log_audit_event(@user, with: oauth['provider'])
sign_in_and_redirect(@user) sign_in_and_redirect(@user)
end end
else else
flash[:alert] = "Access denied for your LDAP account." fail_ldap_login
redirect_to new_user_session_path
end end
end end
...@@ -123,9 +122,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -123,9 +122,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
sign_in_and_redirect(@user) sign_in_and_redirect(@user)
end end
else else
error_message = @user.errors.full_messages.to_sentence fail_login
return redirect_to omniauth_error_path(oauth['provider'], error: error_message)
end end
end end
...@@ -146,6 +143,18 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -146,6 +143,18 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
@oauth ||= request.env['omniauth.auth'] @oauth ||= request.env['omniauth.auth']
end end
def fail_login
error_message = @user.errors.full_messages.to_sentence
return redirect_to omniauth_error_path(oauth['provider'], error: error_message)
end
def fail_ldap_login
flash[:alert] = 'Access denied for your LDAP account.'
redirect_to new_user_session_path
end
def log_audit_event(user, options = {}) def log_audit_event(user, options = {})
AuditEventService.new(user, user, options) AuditEventService.new(user, user, options)
.for_authentication.security_event .for_authentication.security_event
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment