[Web] revert configurable authsource

This commit is contained in:
FreddleSpl0it 2023-05-16 11:10:41 +02:00
parent 663d33d770
commit 1bf8beaa58
No known key found for this signature in database
GPG Key ID: 00E14E7634F4BEC5
4 changed files with 8 additions and 67 deletions

View File

@ -1005,7 +1005,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
); );
return false; return false;
} }
if (in_array($_data['authsource'], array('mailcow', 'keycloak'))){ if (in_array($_data['authsource'], array('mailcow', 'keycloak', 'generic-oidc'))){
$authsource = $_data['authsource']; $authsource = $_data['authsource'];
} }
$password = $_data['password']; $password = $_data['password'];
@ -1500,9 +1500,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
// check attributes // check attributes
$authsources = array('mailcow', 'keycloak');
$attr = array(); $attr = array();
$attr["authsource"] = (isset($_data['authsource']) && in_array($_data['authsource'], $authsources)) ? $_data['authsource'] : 'mailcow';
$attr["quota"] = isset($_data['quota']) ? intval($_data['quota']) * 1048576 : 0; $attr["quota"] = isset($_data['quota']) ? intval($_data['quota']) * 1048576 : 0;
$attr['tags'] = (isset($_data['tags'])) ? $_data['tags'] : array(); $attr['tags'] = (isset($_data['tags'])) ? $_data['tags'] : array();
$attr["quarantine_notification"] = (!empty($_data['quarantine_notification'])) ? $_data['quarantine_notification'] : strval($MAILBOX_DEFAULT_ATTRIBUTES['quarantine_notification']); $attr["quarantine_notification"] = (!empty($_data['quarantine_notification'])) ? $_data['quarantine_notification'] : strval($MAILBOX_DEFAULT_ATTRIBUTES['quarantine_notification']);
@ -3184,9 +3182,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$_data["template"] = (isset($_data["template"])) ? $_data["template"] : $is_now["template"]; $_data["template"] = (isset($_data["template"])) ? $_data["template"] : $is_now["template"];
} }
// check attributes // check attributes
$authsources = array('mailcow', 'keycloak');
$attr = array(); $attr = array();
$attr["authsource"] = (isset($_data['authsource']) && in_array($_data['authsource'], $authsources)) ? $_data['authsource'] : $is_now['authsource'];
$attr["quota"] = isset($_data['quota']) ? intval($_data['quota']) * 1048576 : 0; $attr["quota"] = isset($_data['quota']) ? intval($_data['quota']) * 1048576 : 0;
$attr['tags'] = (isset($_data['tags'])) ? $_data['tags'] : $is_now['tags']; $attr['tags'] = (isset($_data['tags'])) ? $_data['tags'] : $is_now['tags'];
$attr["quarantine_notification"] = (!empty($_data['quarantine_notification'])) ? $_data['quarantine_notification'] : $is_now['quarantine_notification']; $attr["quarantine_notification"] = (!empty($_data['quarantine_notification'])) ? $_data['quarantine_notification'] : $is_now['quarantine_notification'];

View File

@ -162,17 +162,6 @@ $(document).ready(function() {
} }
}); });
}); });
// @selecting identity provider mbox_add_modal
$('#mbox_add_iam').on('change', function(){
// toggle password fields
if (this.value === 'mailcow'){
$('#mbox_add_pwds').removeClass('d-none');
$('#mbox_add_pwds').find('.form-control').prop('required', true);
} else {
$('#mbox_add_pwds').addClass('d-none');
$('#mbox_add_pwds').find('.form-control').prop('required', false);
}
});
// Sieve data modal // Sieve data modal
$('#sieveDataModal').on('show.bs.modal', function(e) { $('#sieveDataModal').on('show.bs.modal', function(e) {
var sieveScript = $(e.relatedTarget).data('sieve-script'); var sieveScript = $(e.relatedTarget).data('sieve-script');
@ -280,15 +269,6 @@ $(document).ready(function() {
} }
function setMailboxTemplateData(template){ function setMailboxTemplateData(template){
$("#addInputQuota").val(template.quota / 1048576); $("#addInputQuota").val(template.quota / 1048576);
$('#mbox_add_iam').selectpicker('val', template.authsource);
// toggle password fields
if (!template.authsource || template.authsource === 'mailcow'){
$('#mbox_add_pwds').removeClass('d-none');
$('#mbox_add_pwds').find('.form-control').prop('required', true);
} else {
$('#mbox_add_pwds').addClass('d-none');
$('#mbox_add_pwds').find('.form-control').prop('required', false);
}
if (template.quarantine_notification === "never"){ if (template.quarantine_notification === "never"){
$('#quarantine_notification_never').prop('checked', true); $('#quarantine_notification_never').prop('checked', true);
@ -1268,15 +1248,6 @@ jQuery(function($){
data: 'attributes.quota', data: 'attributes.quota',
defaultContent: '', defaultContent: '',
}, },
{
title: lang.iam,
data: 'attributes.authsource',
defaultContent: '',
render: function (data, type) {
data = data ? '<span class="badge bg-primary">' + data + '<i class="ms-2 bi bi-person-circle"></i></i></span>' : '<i class="bi bi-x-lg"></i>';
return data;
}
},
{ {
title: lang.tls_enforce_in, title: lang.tls_enforce_in,
data: 'attributes.tls_enforce_in', data: 'attributes.tls_enforce_in',

View File

@ -19,15 +19,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row mb-2">
<label class="control-label col-sm-2" for="authsource">{{ lang.admin.iam }}</label>
<div class="col-sm-10">
<select class="full-width-select" data-live-search="true" id="mbox_template_iam" name="authsource" required>
<option {% if template.attributes.authsource == 'mailcow' %}selected{% endif %}>mailcow</option>
<option {% if template.attributes.authsource == 'keycloak' %}selected{% endif %}>keycloak</option>
</select>
</div>
</div>
<div class="row mb-2"> <div class="row mb-2">
<label class="control-label col-sm-2">{{ lang.add.tags }}</label> <label class="control-label col-sm-2">{{ lang.add.tags }}</label>
<div class="col-sm-10"> <div class="col-sm-10">

View File

@ -11,19 +11,20 @@
<input type="hidden" value="0" name="force_pw_update"> <input type="hidden" value="0" name="force_pw_update">
<input type="hidden" value="0" name="sogo_access"> <input type="hidden" value="0" name="sogo_access">
<input type="hidden" value="0" name="protocol_access"> <input type="hidden" value="0" name="protocol_access">
<input type="hidden" value="mailcow" name="authsource">
<div class="row mb-2">
<label class="control-label col-sm-2 text-sm-end text-sm-end" for="name">{{ lang.add.full_name }}</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name">
</div>
</div>
<div class="row mb-2"> <div class="row mb-2">
<label class="control-label col-sm-2 text-sm-end text-sm-end" for="local_part">{{ lang.add.mailbox_username }}</label> <label class="control-label col-sm-2 text-sm-end text-sm-end" for="local_part">{{ lang.add.mailbox_username }}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" pattern="[A-Za-z0-9\.!#$%&'*+/=?^_`{|}~-]+" autocorrect="off" autocapitalize="none" class="form-control" name="local_part" required> <input type="text" pattern="[A-Za-z0-9\.!#$%&'*+/=?^_`{|}~-]+" autocorrect="off" autocapitalize="none" class="form-control" name="local_part" required>
</div> </div>
</div> </div>
<div class="row mb-2">
<label class="control-label col-sm-2 text-sm-end text-sm-end" for="name">{{ lang.add.full_name }}</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name">
</div>
</div>
<div class="row mb-2"> <div class="row mb-2">
<label class="control-label col-sm-2 text-sm-end text-sm-end" for="domain">{{ lang.add.domain }}</label> <label class="control-label col-sm-2 text-sm-end text-sm-end" for="domain">{{ lang.add.domain }}</label>
<div class="col-sm-10"> <div class="col-sm-10">
@ -41,15 +42,6 @@
</select> </select>
</div> </div>
</div> </div>
<div class="row mb-2">
<label class="control-label col-sm-2 text-sm-end text-sm-end" for="authsource">{{ lang.admin.iam }}</label>
<div class="col-sm-10">
<select class="full-width-select" data-live-search="true" id="mbox_add_iam" name="authsource" required>
<option selected>mailcow</option>
<option>keycloak</option>
</select>
</div>
</div>
<div id="mbox_add_pwds"> <div id="mbox_add_pwds">
<div class="row mb-2"> <div class="row mb-2">
<label class="control-label col-sm-2 text-sm-end text-sm-end" for="password">{{ lang.add.password }} (<a href="#" class="generate_password">{{ lang.add.generate }}</a>)</label> <label class="control-label col-sm-2 text-sm-end text-sm-end" for="password">{{ lang.add.password }} (<a href="#" class="generate_password">{{ lang.add.generate }}</a>)</label>
@ -237,15 +229,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row mb-2">
<label class="control-label col-sm-2 text-sm-end text-sm-end" for="authsource">{{ lang.admin.iam }}</label>
<div class="col-sm-10">
<select class="full-width-select" data-live-search="true" id="mbox_template_iam" name="authsource">
<option selected>mailcow</option>
<option>keycloak</option>
</select>
</div>
</div>
<div class="row mb-2"> <div class="row mb-2">
<label class="control-label col-sm-2 text-sm-end text-sm-end">{{ lang.add.tags }}</label> <label class="control-label col-sm-2 text-sm-end text-sm-end">{{ lang.add.tags }}</label>
<div class="col-sm-10"> <div class="col-sm-10">