mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-23 02:27:05 +00:00
removing the ability to configure the default quota -- default quota is always unlimited.
This commit is contained in:
parent
c01a1d5493
commit
ceaf5338be
@ -60,7 +60,6 @@ def setup_key_auth(mgmt_uri):
|
|||||||
|
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print("""Usage:
|
print("""Usage:
|
||||||
{cli} system default-quota [new default] (set default quota for system)
|
|
||||||
{cli} user (lists users)
|
{cli} user (lists users)
|
||||||
{cli} user add user@domain.com [password]
|
{cli} user add user@domain.com [password]
|
||||||
{cli} user password user@domain.com [password]
|
{cli} user password user@domain.com [password]
|
||||||
@ -152,12 +151,6 @@ elif sys.argv[1] == "alias" and sys.argv[2] == "add" and len(sys.argv) == 5:
|
|||||||
elif sys.argv[1] == "alias" and sys.argv[2] == "remove" and len(sys.argv) == 4:
|
elif sys.argv[1] == "alias" and sys.argv[2] == "remove" and len(sys.argv) == 4:
|
||||||
print(mgmt("/mail/aliases/remove", { "address": sys.argv[3] }))
|
print(mgmt("/mail/aliases/remove", { "address": sys.argv[3] }))
|
||||||
|
|
||||||
elif sys.argv[1] == "system" and sys.argv[2] == "default-quota" and len(sys.argv) == 3:
|
|
||||||
print(mgmt("/system/default-quota?text=1"))
|
|
||||||
|
|
||||||
elif sys.argv[1] == "system" and sys.argv[2] == "default-quota" and len(sys.argv) == 4:
|
|
||||||
print(mgmt("/system/default-quota", { "default_quota": sys.argv[3]}))
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Invalid command-line arguments.")
|
print("Invalid command-line arguments.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -21,7 +21,7 @@ import auth, utils
|
|||||||
from mailconfig import get_mail_users, get_mail_users_ex, get_admins, add_mail_user, set_mail_password, remove_mail_user
|
from mailconfig import get_mail_users, get_mail_users_ex, get_admins, add_mail_user, set_mail_password, remove_mail_user
|
||||||
from mailconfig import get_mail_user_privileges, add_remove_mail_user_privilege
|
from mailconfig import get_mail_user_privileges, add_remove_mail_user_privilege
|
||||||
from mailconfig import get_mail_aliases, get_mail_aliases_ex, get_mail_domains, add_mail_alias, remove_mail_alias
|
from mailconfig import get_mail_aliases, get_mail_aliases_ex, get_mail_domains, add_mail_alias, remove_mail_alias
|
||||||
from mailconfig import get_mail_quota, set_mail_quota, get_default_quota, validate_quota
|
from mailconfig import get_mail_quota, set_mail_quota
|
||||||
from mfa import get_public_mfa_state, provision_totp, validate_totp_secret, enable_mfa, disable_mfa
|
from mfa import get_public_mfa_state, provision_totp, validate_totp_secret, enable_mfa, disable_mfa
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ def mail_users():
|
|||||||
@app.route('/mail/users/add', methods=['POST'])
|
@app.route('/mail/users/add', methods=['POST'])
|
||||||
@authorized_personnel_only
|
@authorized_personnel_only
|
||||||
def mail_users_add():
|
def mail_users_add():
|
||||||
quota = request.form.get('quota', get_default_quota(env))
|
quota = request.form.get('quota', '0')
|
||||||
try:
|
try:
|
||||||
return add_mail_user(request.form.get('email', ''), request.form.get('password', ''), request.form.get('privileges', ''), quota, env)
|
return add_mail_user(request.form.get('email', ''), request.form.get('password', ''), request.form.get('privileges', ''), quota, env)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -675,29 +675,6 @@ def privacy_status_set():
|
|||||||
utils.write_settings(config, env)
|
utils.write_settings(config, env)
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|
||||||
@app.route('/system/default-quota', methods=["GET"])
|
|
||||||
@authorized_personnel_only
|
|
||||||
def default_quota_get():
|
|
||||||
if request.values.get('text'):
|
|
||||||
return get_default_quota(env)
|
|
||||||
else:
|
|
||||||
return json_response({
|
|
||||||
"default-quota": get_default_quota(env),
|
|
||||||
})
|
|
||||||
|
|
||||||
@app.route('/system/default-quota', methods=["POST"])
|
|
||||||
@authorized_personnel_only
|
|
||||||
def default_quota_set():
|
|
||||||
config = utils.load_settings(env)
|
|
||||||
try:
|
|
||||||
config["default-quota"] = validate_quota(request.values.get('default_quota'))
|
|
||||||
utils.write_settings(config, env)
|
|
||||||
|
|
||||||
except ValueError as e:
|
|
||||||
return ("ERROR: %s" % str(e), 400)
|
|
||||||
|
|
||||||
return "OK"
|
|
||||||
|
|
||||||
# MUNIN
|
# MUNIN
|
||||||
|
|
||||||
@app.route('/munin/')
|
@app.route('/munin/')
|
||||||
|
@ -344,7 +344,7 @@ def add_mail_user(email, pw, privs, quota, env):
|
|||||||
if validation: return validation
|
if validation: return validation
|
||||||
|
|
||||||
if quota is None:
|
if quota is None:
|
||||||
quota = get_default_quota()
|
quota = '0'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
quota = validate_quota(quota)
|
quota = validate_quota(quota)
|
||||||
@ -429,10 +429,6 @@ def dovecot_quota_recalc(email):
|
|||||||
# force dovecot to recalculate the quota info for the user.
|
# force dovecot to recalculate the quota info for the user.
|
||||||
subprocess.call(["doveadm", "quota", "recalc", "-u", email])
|
subprocess.call(["doveadm", "quota", "recalc", "-u", email])
|
||||||
|
|
||||||
def get_default_quota(env):
|
|
||||||
config = utils.load_settings(env)
|
|
||||||
return config.get("default-quota", '0')
|
|
||||||
|
|
||||||
def validate_quota(quota):
|
def validate_quota(quota):
|
||||||
# validate quota
|
# validate quota
|
||||||
quota = quota.strip().upper()
|
quota = quota.strip().upper()
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="sr-only" for="adduserQuota">Quota</label>
|
<label class="sr-only" for="adduserQuota">Quota</label>
|
||||||
<input type="text" class="form-control" id="adduserQuota" placeholder="Quota" style="width:5em;">
|
<input type="text" class="form-control" id="adduserQuota" placeholder="Quota" style="width:5em;" value="0">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Add User</button>
|
<button type="submit" class="btn btn-primary">Add User</button>
|
||||||
</form>
|
</form>
|
||||||
@ -165,15 +165,6 @@ curl -X POST -d "email=new_user@mydomail.com" https://{{hostname}}/admin/mail/us
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
function show_users() {
|
function show_users() {
|
||||||
api(
|
|
||||||
"/system/default-quota",
|
|
||||||
"GET",
|
|
||||||
{},
|
|
||||||
function(r) {
|
|
||||||
$('#adduserQuota').val(r['default-quota']);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$('#user_table tbody').html("<tr><td colspan='2' class='text-muted'>Loading...</td></tr>")
|
$('#user_table tbody').html("<tr><td colspan='2' class='text-muted'>Loading...</td></tr>")
|
||||||
api(
|
api(
|
||||||
"/mail/users",
|
"/mail/users",
|
||||||
|
@ -193,8 +193,7 @@ def migration_14(env):
|
|||||||
def migration_15(env):
|
def migration_15(env):
|
||||||
# Add a column to the users table to store their quota limit. Default to '0' for unlimited.
|
# Add a column to the users table to store their quota limit. Default to '0' for unlimited.
|
||||||
db = os.path.join(env["STORAGE_ROOT"], 'mail/users.sqlite')
|
db = os.path.join(env["STORAGE_ROOT"], 'mail/users.sqlite')
|
||||||
shell("check_call", ["sqlite3", db,
|
shell("check_call", ["sqlite3", db, "ALTER TABLE users ADD COLUMN quota TEXT NOT NULL DEFAULT '0';"])
|
||||||
"ALTER TABLE users ADD COLUMN quota TEXT NOT NULL DEFAULT '0';"])
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user