Ejemplo n.º 1
0
def add_administrative_user(allow_profile_defaults=True):
    from getpass import getpass
    from compstack.auth.model.orm import User

    input_function = input
    if six.PY2:
        input_function = raw_input  # noqa

    defaults = settings.components.auth.admin
    # add a default administrative user
    if allow_profile_defaults and defaults.username and defaults.password and defaults.email:
        ulogin = defaults.username
        uemail = defaults.email
        p1 = defaults.password
    else:
        ulogin = input_function("User's Login id:\n> ")
        uemail = input_function("User's email:\n> ")
        while True:
            p1 = getpass("User's password:\n> ")
            p2 = getpass("confirm password:\n> ")
            if p1 == p2:
                break
    User.add_iu(
        login_id=six.text_type(ulogin),
        email_address=six.text_type(uemail),
        password=p1,
        super_user=True,
        reset_required=False,
        pass_reset_ok=False,
    )
Ejemplo n.º 2
0
def test_user_unique():
    u1 = create_user_with_permissions()
    u2 = User.add_iu(login_id=u1.login_id, email_address='*****@*****.**' % u1.login_id)
    assert u2 is None, '%s, %s' % (u1.id, u2.id)
    u2 = User.add_iu(login_id='test%s' % u1.login_id, email_address=u1.email_address)
    assert u2 is None