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);
if ($validator->fails()) {
\Log::debug('LDAP Validation test failed.');
$validation_errors = implode(' ',$validator->errors()->all());
return response()->json(['message' => $validator->errors()->all()], 400);
}
@ -153,7 +154,7 @@ class SettingsController extends Controller
}
} catch (\Exception $e) {
\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;
}
\Log::debug('Attempting to login using distinguished name:'.$userDn);
$filterQuery = $settings->ldap_auth_filter_query . $username;

View file

@ -335,10 +335,12 @@
Test LDAP Sync
</div>
<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>
<span id="ldaptesticon"></span>
<span id="ldaptestresult"></span>
<span id="ldapteststatus"></span>
<a class="btn btn-default btn-sm pull-left" id="ldaptest" style="margin-right: 10px;">Test LDAP</a>
</div>
<div class="col-md-9 col-md-offset-3">
<span id="ldaptesticon"></span>
<span id="ldaptestresult"></span>
<span id="ldapteststatus"></span>
</div>
<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>
@ -350,7 +352,7 @@
<div class="col-md-3">
Test LDAP Login
</div>
<div class="col-md-9" id="ldaptestloginrow">
<div class="col-md-9">
<div class="row">
<div class="col-md-4">
<input type="text" name="ldaptest_user" id="ldaptest_user" class="form-control" placeholder="LDAP username">
@ -361,12 +363,12 @@
<div class="col-md-3">
<a class="btn btn-default btn-sm" id="ldaptestlogin" style="margin-right: 10px;">Test LDAP</a>
</div>
<span id="ldaptestloginicon"></span>
</div>
</div>
<div class="col-md-9 col-md-offset-3">
<span id="ldaptestloginicon"></span>
<span id="ldaptestloginresult"></span>
<span id="ldaptestloginstatus"></span>
</div>
@ -404,10 +406,10 @@
@section('moar_scripts')
<script nonce="{{ csrf_token() }}">
$("#ldaptest").click(function(){
$("#ldaptestrow").removeClass('success');
$("#ldaptestrow").removeClass('danger');
$("#ldaptestrow").removeClass('text-success');
$("#ldaptestrow").removeClass('text-danger');
$("#ldapteststatus").html('');
$("#ldaptesticon").html('<i class="fa fa-spinner spin"></i>');
$("#ldaptesticon").html('<i class="fa fa-spinner spin"></i> Testing...');
$.ajax({
url: '{{ route('api.settings.ldaptest') }}',
type: 'GET',
@ -420,16 +422,30 @@
success: function (data) {
$("#ldaptesticon").html('');
$("#ldaptestrow").addClass('success');
$("#ldapteststatus").addClass('text-success');
$("#ldapteststatus").html('<i class="fa fa-check text-success"></i> It worked!');
},
error: function (data) {
//console.dir(data);
$("#ldaptesticon").html('');
$("#ldaptestrow").addClass('danger');
$("#ldapteststatus").addClass('text-danger');
$("#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(){
$("#ldaptestloginrow").removeClass('success');
$("#ldaptestloginrow").removeClass('danger');
$("#ldaptestloginrow").removeClass('text-success');
$("#ldaptestloginrow").removeClass('text-danger');
$("#ldaptestloginstatus").html('');
$("#ldaptestloginicon").html('<i class="fa fa-spinner spin"></i>');
$("#ldaptestloginicon").html('<i class="fa fa-spinner spin"></i> Testing...');
$.ajax({
url: '{{ route('api.settings.ldaptestlogin') }}',
type: 'POST',
@ -457,19 +473,44 @@
success: function (data) {
$("#ldaptestloginicon").html('');
$("#ldaptestloginrow").addClass('success');
$("#ldaptestloginrow").addClass('text-success');
$("#ldaptestloginstatus").html('<i class="fa fa-check text-success"></i> It worked!');
},
error: function (data) {
//console.dir(data);
if (data.responseJSON) {
var errors = data.responseJSON.message;
} else {
var errors;
}
var error_text;
$("#ldaptestloginicon").html('');
$("#ldaptestloginrow").addClass('danger');
$("#ldaptestloginstatus").addClass('text-danger');
$("#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);
}
}
});
});