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_prefix = data["alias_prefix"]
alias_suffix = data["alias_suffix"] 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 = alias_prefix.strip()
alias_prefix = convert_to_id(alias_prefix) alias_prefix = convert_to_id(alias_prefix)
if not alias_prefix: # should be checked on frontend if not alias_prefix: # should be checked on frontend

View file

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

View file

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