mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +00:00
feat: Allow underscores and hyphens in account name
This commit is contained in:
parent
beed738d02
commit
a3c50828a6
@ -35,7 +35,7 @@ class Account(db.Model):
|
|||||||
|
|
||||||
if self.name is not None:
|
if self.name is not None:
|
||||||
self.name = ''.join(c for c in self.name.lower()
|
self.name = ''.join(c for c in self.name.lower()
|
||||||
if c in "abcdefghijklmnopqrstuvwxyz0123456789")
|
if c in "abcdefghijklmnopqrstuvwxyz0123456789_-")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Account {0}r>'.format(self.name)
|
return '<Account {0}r>'.format(self.name)
|
||||||
|
@ -331,7 +331,7 @@ def login():
|
|||||||
# check if user has permissions
|
# check if user has permissions
|
||||||
account_users = account.get_user()
|
account_users = account.get_user()
|
||||||
current_app.logger.info('Group: {} Users: {}'.format(
|
current_app.logger.info('Group: {} Users: {}'.format(
|
||||||
group_name,
|
group_name,
|
||||||
account_users))
|
account_users))
|
||||||
if user.id in account_users:
|
if user.id in account_users:
|
||||||
current_app.logger.info('User id {} is already in account {}'.format(
|
current_app.logger.info('User id {} is already in account {}'.format(
|
||||||
@ -351,7 +351,7 @@ def login():
|
|||||||
account.mail = ''
|
account.mail = ''
|
||||||
account.create_account()
|
account.create_account()
|
||||||
history = History(msg='Create account {0}'.format(
|
history = History(msg='Create account {0}'.format(
|
||||||
account.name),
|
account.name),
|
||||||
created_by='System')
|
created_by='System')
|
||||||
history.add()
|
history.add()
|
||||||
|
|
||||||
@ -485,13 +485,13 @@ def login():
|
|||||||
saml_enabled=SAML_ENABLED,
|
saml_enabled=SAML_ENABLED,
|
||||||
error='Token required')
|
error='Token required')
|
||||||
|
|
||||||
if Setting().get('autoprovisioning') and auth_method!='LOCAL':
|
if Setting().get('autoprovisioning') and auth_method!='LOCAL':
|
||||||
urn_value=Setting().get('urn_value')
|
urn_value=Setting().get('urn_value')
|
||||||
Entitlements=user.read_entitlements(Setting().get('autoprovisioning_attribute'))
|
Entitlements=user.read_entitlements(Setting().get('autoprovisioning_attribute'))
|
||||||
if len(Entitlements)==0 and Setting().get('purge'):
|
if len(Entitlements)==0 and Setting().get('purge'):
|
||||||
user.set_role("User")
|
user.set_role("User")
|
||||||
user.revoke_privilege(True)
|
user.revoke_privilege(True)
|
||||||
|
|
||||||
elif len(Entitlements)!=0:
|
elif len(Entitlements)!=0:
|
||||||
if checkForPDAEntries(Entitlements, urn_value):
|
if checkForPDAEntries(Entitlements, urn_value):
|
||||||
user.updateUser(Entitlements)
|
user.updateUser(Entitlements)
|
||||||
@ -1093,7 +1093,7 @@ def create_group_to_account_mapping():
|
|||||||
|
|
||||||
def handle_account(account_name, account_description=""):
|
def handle_account(account_name, account_description=""):
|
||||||
clean_name = ''.join(c for c in account_name.lower()
|
clean_name = ''.join(c for c in account_name.lower()
|
||||||
if c in "abcdefghijklmnopqrstuvwxyz0123456789")
|
if c in "abcdefghijklmnopqrstuvwxyz0123456789_-")
|
||||||
if len(clean_name) > Account.name.type.length:
|
if len(clean_name) > Account.name.type.length:
|
||||||
current_app.logger.error(
|
current_app.logger.error(
|
||||||
"Account name {0} too long. Truncated.".format(clean_name))
|
"Account name {0} too long. Truncated.".format(clean_name))
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
<span class="fa fa-cog form-control-feedback"></span>
|
<span class="fa fa-cog form-control-feedback"></span>
|
||||||
{% if invalid_accountname %}
|
{% if invalid_accountname %}
|
||||||
<span class="help-block">Cannot be blank and must only contain alphanumeric
|
<span class="help-block">Cannot be blank and must only contain alphanumeric
|
||||||
characters.</span>
|
characters, hyphens or underscores.</span>
|
||||||
{% elif duplicate_accountname %}
|
{% elif duplicate_accountname %}
|
||||||
<span class="help-block">Account name already in use.</span>
|
<span class="help-block">Account name already in use.</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -112,8 +112,8 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>Fill in all the fields to the in the form to the left.</p>
|
<p>Fill in all the fields to the in the form to the left.</p>
|
||||||
<p>
|
<p>
|
||||||
<strong>Name</strong> is an account identifier. It will be stored as all lowercase letters (no
|
<strong>Name</strong> is an account identifier. It will be lowercased and can contain alphanumeric
|
||||||
spaces, special characters etc).<br />
|
characters, hyphens and underscores (no space or other special character is allowed).<br />
|
||||||
<strong>Description</strong> is a user friendly name for this account.<br />
|
<strong>Description</strong> is a user friendly name for this account.<br />
|
||||||
<strong>Contact person</strong> is the name of a contact person at the account.<br />
|
<strong>Contact person</strong> is the name of a contact person at the account.<br />
|
||||||
<strong>Mail Address</strong> is an e-mail address for the contact person.
|
<strong>Mail Address</strong> is an e-mail address for the contact person.
|
||||||
|
Loading…
Reference in New Issue
Block a user