remove >3 characters on alias prefix

This commit is contained in:
Son NK 2019-12-06 10:28:00 +01:00
parent 6e387444f5
commit ca05cd359a
4 changed files with 14 additions and 11 deletions

View file

@ -37,7 +37,7 @@ def new_custom_alias():
alias_prefix = data["alias_prefix"]
alias_suffix = data["alias_suffix"]
# make sure alias_prefix is more than 3 chars
# make sure alias_prefix is not empty
alias_prefix = alias_prefix.strip()
alias_prefix = convert_to_id(alias_prefix)
if not alias_prefix: # should be checked on frontend

View file

@ -39,7 +39,7 @@
</div>
{% endfor %}
</div>
{% endblock %}
{% block script %}

View file

@ -18,16 +18,17 @@
<input type="hidden" name="form-name" value="non-custom-domain-name">
<div class="form-group">
<label class="form-label font-weight-bold">SimpleLogin domain</label>
<label class="form-label font-weight-bold">With SimpleLogin domain</label>
<small class="text-muted">
You can use letter, number or dash. Alias must have at least 3 characters
You can use letter, number or dash. Alias prefix cannot be empty.
</small>
<div class="row mt-4">
<div class="col">
<input name="email-prefix" class="form-control" pattern="[0-9|A-Z|a-z|-]{3,}"
title="Only letter, number or dash can be used and alias must have at least 3 characters."
autofocus>
<input name="email-prefix" class="form-control" pattern="[0-9|A-Z|a-z|-]{1,}"
title="Only letter, number or dash can be used."
placeholder="alias prefix"
autofocus required>
</div>
<div class="col align-self-center">
<input type="hidden" name="email-suffix" value="{{ email_suffix }}">
@ -35,10 +36,12 @@
.{{ email_suffix }}@{{ EMAIL_DOMAIN }}
</h4>
</div>
<div class="col">
<button class="btn btn-primary btn-sm">Create</button>
</div>
</div>
</div>
<button class="btn btn-primary">Create</button>
</form>
{% if custom_domains %}

View file

@ -28,8 +28,8 @@ def custom_alias():
email_prefix = convert_to_id(email_prefix)
email_suffix = request.form.get("email-suffix")
if len(email_prefix) < 3:
error = "email must be at least 3 letters"
if not email_prefix:
error = "alias prefix cannot be empty"
else:
full_email = f"{email_prefix}.{email_suffix}@{EMAIL_DOMAIN}"
# check if email already exists