Better error messages for failed LDAP logons
I've been trying to diagnose an issues when logging in via LDAP but the error message presented to the user is less than ideal:
Could not authenticate you from Ldapmain because "Undefined method `provider' for nil:nilclass".
This happens in this instance due to an invalid email address in ldap and can be found in the application log:
December 04, 2015 13:07: (OAuth) Error saving user: ["Email is invalid", "Notification email is invalid"]
But the production log isn't that much use either:
13:07:11 web.1 | I, [2015-12-04T13:07:11.021585 #35442] INFO -- omniauth: (ldapmain) Callback phase initiated.
13:07:11 web.1 | E, [2015-12-04T13:07:11.400380 #35442] ERROR -- omniauth: (ldapmain) Authentication failure! ldap_error: NoMethodError, undefined method `provider' for nil:NilClass
But having something more user accessible to diagnose the issue would be a lot more helpful.
I've seen a few instances of this error, this is the first time I've been able to reproduce it on my dev environment rather than production which makes it easier to raise an issue for.