From b107280b7b05860ccca3f3ca80e3ae927f5e6784 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 16 Oct 2017 06:39:36 -0700 Subject: [PATCH] Slightly nicer UI for LDAP login test --- app/Http/Controllers/Api/SettingsController.php | 8 ++++++-- resources/views/settings/ldap.blade.php | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/SettingsController.php b/app/Http/Controllers/Api/SettingsController.php index 81d9d32320..9230a21ec7 100644 --- a/app/Http/Controllers/Api/SettingsController.php +++ b/app/Http/Controllers/Api/SettingsController.php @@ -107,11 +107,15 @@ class SettingsController extends Controller try { $connection = Ldap::connectToLdap(); try { - \Log::debug('attempting to bind to LDAP for LDAP test'); + \Log::debug('Attempting to bind to LDAP for LDAP test'); Ldap::bindAdminToLdap($connection); try { $ldap_user = Ldap::findAndBindUserLdap($request->input('ldaptest_user'), $request->input('ldaptest_password')); - return response()->json(['message' => 'It worked! '. $request->input('username').' successfully binded to LDAP.'], 200); + if ($ldap_user) { + return response()->json(['message' => 'It worked! '. $request->input('username').' successfully binded to LDAP.'], 200); + } + return response()->json(['message' => 'Login Failed. '. $request->input('username').' successfully binded to LDAP.'], 400); + } catch (\Exception $e) { \Log::debug('LDAP login failed'); return response()->json(['message' => $e->getMessage()], 400); diff --git a/resources/views/settings/ldap.blade.php b/resources/views/settings/ldap.blade.php index 4ed8661d21..82496a8c7f 100644 --- a/resources/views/settings/ldap.blade.php +++ b/resources/views/settings/ldap.blade.php @@ -361,11 +361,15 @@
Test LDAP
- + + + + +
+
-

Enter a valid LDAP username and password to test whether your LDAP login is configured correctly.