Beispiel #1
0
def create_user(name,
                email,
                groups,
                default_sharing,
                permissions,
                password=None):
    user = User.get(email=email.lower())

    if user:
        print "/!\ User with this email address already exists."
    else:
        user = User({
            'name': name,
            'email': email.lower(),
            'groups': groups,
            'default_sharing': default_sharing,
            'permissions': permissions,
            'enabled': True
        })
        if password:
            user['pwd_hash'] = generate_password_hash(password)
        user.save()
        print "[+] User created."

        user.generate_avatar()
        print "[+] Downloaded avatar."

    return user
Beispiel #2
0
def create_user(saml_name_id, saml_user_data):

    role = saml_user_data[ROLE_KEY][0]

    user = User({
        'saml_name_id': saml_name_id,
        'name': saml_name_id,
        'groups': ROLE_MAPPING[role]['groups'],
        'default_sharing': ROLE_MAPPING[role]['default_sharing'],
        'permissions': ROLE_MAPPING[role]['permissions'],
        'enabled': True
    })
    user.save()
    user.generate_avatar()

    return user
Beispiel #3
0
def get_or_create_user():
    user = User.get(email="admin@fame")

    if not user:
        user = User({
            'name': "admin",
            'email': "admin@fame",
            'groups': ['admin', '*'],
            'default_sharing': ['admin'],
            'permissions': ['*'],
            'enabled': True
        })
        user.save()
        user.generate_avatar()

    return user
Beispiel #4
0
def create_user(ldap_user):
    groups = get_mapping(ldap_user['groups'], "groups")
    default_sharing = get_mapping(ldap_user['groups'], "default_sharing")
    permissions = get_mapping(ldap_user["groups"], "permissions")

    user = User({
        'name': ldap_user['name'],
        'email': ldap_user['mail'],
        'enabled': ldap_user['enabled'],
        'groups': groups,
        'default_sharing': default_sharing,
        'permissions': permissions,
    })
    user.save()
    user.generate_avatar()

    return user