MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / validate_user

Function validate_user

web/pgadmin/tools/user_management/__init__.py:603–636  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

601
602
603def validate_user(data):
604 new_data = dict()
605
606 validate_unique_user(data)
607
608 validate_password(data, new_data)
609
610 if 'email' in data and data['email'] and data['email'] != "":
611 if validate_email(data['email']):
612 new_data['email'] = data['email']
613 else:
614 raise InternalServerError(
615 _("Invalid email address {0}.").format(data['email']))
616
617 if 'role' in data and data['role'] != "":
618 new_data['roles'] = int(data['role'])
619
620 if 'active' in data and data['active'] != "":
621 new_data['active'] = data['active']
622
623 if 'username' in data and data['username'] != "":
624 new_data['username'] = data['username']
625
626 if 'auth_source' in data and data['auth_source'] != "":
627 new_data['auth_source'] = data['auth_source']
628
629 if 'locked' in data and isinstance(data['locked'], bool):
630 new_data['locked'] = data['locked']
631 if data['locked']:
632 new_data['login_attempts'] = config.MAX_LOGIN_ATTEMPTS
633 else:
634 new_data['login_attempts'] = 0
635
636 return new_data
637
638
639def _create_new_user(new_data):

Callers 3

runTestMethod · 0.90
create_userFunction · 0.85
update_userFunction · 0.85

Calls 3

validate_emailFunction · 0.90
validate_unique_userFunction · 0.85
validate_passwordFunction · 0.85

Tested by 1

runTestMethod · 0.72