Merge branch 'develop'

This commit is contained in:
snipe 2017-10-16 09:01:09 -07:00
commit 938490df16
3 changed files with 64 additions and 20 deletions

View file

@ -123,6 +123,7 @@ class SettingsController extends Controller
$validator = Validator::make($request->all(), $rules); $validator = Validator::make($request->all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
\Log::debug('LDAP Validation test failed.'); \Log::debug('LDAP Validation test failed.');
$validation_errors = implode(' ',$validator->errors()->all());
return response()->json(['message' => $validator->errors()->all()], 400); return response()->json(['message' => $validator->errors()->all()], 400);
} }
@ -153,7 +154,7 @@ class SettingsController extends Controller
} }
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug('Connection failed'); \Log::debug('Connection failed');
return response()->json(['message' => $e->getMessage()], 600); return response()->json(['message' => $e->getMessage()], 500);
} }

View file

@ -96,6 +96,8 @@ class Ldap extends Model
$userDn = $ldap_username_field.'='.$username.','.$settings->ldap_basedn; $userDn = $ldap_username_field.'='.$username.','.$settings->ldap_basedn;
} }
\Log::debug('Attempting to login using distinguished name:'.$userDn);
$filterQuery = $settings->ldap_auth_filter_query . $username; $filterQuery = $settings->ldap_auth_filter_query . $username;

View file

@ -335,10 +335,12 @@
Test LDAP Sync Test LDAP Sync
</div> </div>
<div class="col-md-9" id="ldaptestrow"> <div class="col-md-9" id="ldaptestrow">
<a class="btn btn-default btn-sm pull-left" id="ldaptest" style="margin-right: 10px;"> Test LDAP</a> <a class="btn btn-default btn-sm pull-left" id="ldaptest" style="margin-right: 10px;">Test LDAP</a>
<span id="ldaptesticon"></span> </div>
<span id="ldaptestresult"></span> <div class="col-md-9 col-md-offset-3">
<span id="ldapteststatus"></span> <span id="ldaptesticon"></span>
<span id="ldaptestresult"></span>
<span id="ldapteststatus"></span>
</div> </div>
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3">
<p class="help-block">This only tests that LDAP can sync correctly. If your LDAP Authentication query is not correct, users may still not be able to login.</p> <p class="help-block">This only tests that LDAP can sync correctly. If your LDAP Authentication query is not correct, users may still not be able to login.</p>
@ -350,7 +352,7 @@
<div class="col-md-3"> <div class="col-md-3">
Test LDAP Login Test LDAP Login
</div> </div>
<div class="col-md-9" id="ldaptestloginrow"> <div class="col-md-9">
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<input type="text" name="ldaptest_user" id="ldaptest_user" class="form-control" placeholder="LDAP username"> <input type="text" name="ldaptest_user" id="ldaptest_user" class="form-control" placeholder="LDAP username">
@ -361,12 +363,12 @@
<div class="col-md-3"> <div class="col-md-3">
<a class="btn btn-default btn-sm" id="ldaptestlogin" style="margin-right: 10px;">Test LDAP</a> <a class="btn btn-default btn-sm" id="ldaptestlogin" style="margin-right: 10px;">Test LDAP</a>
</div> </div>
<span id="ldaptestloginicon"></span>
</div> </div>
</div> </div>
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3">
<span id="ldaptestloginicon"></span>
<span id="ldaptestloginresult"></span> <span id="ldaptestloginresult"></span>
<span id="ldaptestloginstatus"></span> <span id="ldaptestloginstatus"></span>
</div> </div>
@ -404,10 +406,10 @@
@section('moar_scripts') @section('moar_scripts')
<script nonce="{{ csrf_token() }}"> <script nonce="{{ csrf_token() }}">
$("#ldaptest").click(function(){ $("#ldaptest").click(function(){
$("#ldaptestrow").removeClass('success'); $("#ldaptestrow").removeClass('text-success');
$("#ldaptestrow").removeClass('danger'); $("#ldaptestrow").removeClass('text-danger');
$("#ldapteststatus").html(''); $("#ldapteststatus").html('');
$("#ldaptesticon").html('<i class="fa fa-spinner spin"></i>'); $("#ldaptesticon").html('<i class="fa fa-spinner spin"></i> Testing...');
$.ajax({ $.ajax({
url: '{{ route('api.settings.ldaptest') }}', url: '{{ route('api.settings.ldaptest') }}',
type: 'GET', type: 'GET',
@ -420,16 +422,30 @@
success: function (data) { success: function (data) {
$("#ldaptesticon").html(''); $("#ldaptesticon").html('');
$("#ldaptestrow").addClass('success'); $("#ldapteststatus").addClass('text-success');
$("#ldapteststatus").html('<i class="fa fa-check text-success"></i> It worked!'); $("#ldapteststatus").html('<i class="fa fa-check text-success"></i> It worked!');
}, },
error: function (data) { error: function (data) {
//console.dir(data); //console.dir(data);
$("#ldaptesticon").html(''); $("#ldaptesticon").html('');
$("#ldaptestrow").addClass('danger'); $("#ldapteststatus").addClass('text-danger');
$("#ldaptesticon").html('<i class="fa fa-exclamation-triangle text-danger"></i>'); $("#ldaptesticon").html('<i class="fa fa-exclamation-triangle text-danger"></i>');
$('#ldapteststatus').text(data.responseText.message);
if (data.status == 500) {
$('#ldapteststatus').html('500 Server Error');
} else if (data.status == 400) {
for (i = 0; i < errors.length; i++) {
if (errors[i]) {
error_text += '<li>Error: ' + errors[i];
}
}
$('#ldapteststatus').html(error_text);
} else {
$('#ldapteststatus').html(data.responseText.message);
}
} }
@ -437,10 +453,10 @@
}); });
$("#ldaptestlogin").click(function(){ $("#ldaptestlogin").click(function(){
$("#ldaptestloginrow").removeClass('success'); $("#ldaptestloginrow").removeClass('text-success');
$("#ldaptestloginrow").removeClass('danger'); $("#ldaptestloginrow").removeClass('text-danger');
$("#ldaptestloginstatus").html(''); $("#ldaptestloginstatus").html('');
$("#ldaptestloginicon").html('<i class="fa fa-spinner spin"></i>'); $("#ldaptestloginicon").html('<i class="fa fa-spinner spin"></i> Testing...');
$.ajax({ $.ajax({
url: '{{ route('api.settings.ldaptestlogin') }}', url: '{{ route('api.settings.ldaptestlogin') }}',
type: 'POST', type: 'POST',
@ -457,19 +473,44 @@
success: function (data) { success: function (data) {
$("#ldaptestloginicon").html(''); $("#ldaptestloginicon").html('');
$("#ldaptestloginrow").addClass('success'); $("#ldaptestloginrow").addClass('text-success');
$("#ldaptestloginstatus").html('<i class="fa fa-check text-success"></i> It worked!'); $("#ldaptestloginstatus").html('<i class="fa fa-check text-success"></i> It worked!');
}, },
error: function (data) { error: function (data) {
//console.dir(data);
if (data.responseJSON) {
var errors = data.responseJSON.message;
} else {
var errors;
}
var error_text;
$("#ldaptestloginicon").html(''); $("#ldaptestloginicon").html('');
$("#ldaptestloginrow").addClass('danger'); $("#ldaptestloginrow").addClass('danger');
$("#ldaptestloginstatus").addClass('text-danger');
$("#ldaptestloginicon").html('<i class="fa fa-exclamation-triangle text-danger"></i>'); $("#ldaptestloginicon").html('<i class="fa fa-exclamation-triangle text-danger"></i>');
$('#ldaptestloginstatus').text(data.responseText.message);
if (data.status == 500) {
$('#ldaptestloginstatus').html('500 Server Error');
} else if (data.status == 400) {
for (i = 0; i < errors.length; i++) {
if (errors[i]) {
error_text += '<li>Error: ' + errors[i];
}
}
$('#ldaptestloginstatus').html(error_text);
} else {
$('#ldaptestloginstatus').html(data.responseText.message);
}
} }
}); });
}); });