Beispiel #1
0
def create_role(rolename=None):
    if not rolename:
        raise NameError('You must specify a rolename')
    db = application.get_db_connection()
    if not list(db.roles.find({'rolename': rolename})):
        data = schema.role(rolename)
        db.roles.insert(data)
    return True
Beispiel #2
0
def create_role(rolename=None):
    if not rolename:
        raise NameError('You must specify a rolename')
    db = application.get_db_connection()
    if not list(db.roles.find({'rolename': rolename})):
        data = schema.role(rolename)
        db.roles.insert(data)
    return True
Beispiel #3
0
def create_role(rolename=None):
    if not rolename:
        raise NameError('You must specify a rolename')
    db = application.get_db_connection()
    role_key = schema.ROLE_KEY.format(rolename)
    data = schema.role(rolename)
    db.set(role_key, json.dumps(data))
    return True
Beispiel #4
0
def create_user():
    db = get_db_connection()
    try:
        username = raw_input('Username: '******'Email: ').strip()
        while True:
            password = getpass('Password: '******' (confirm): ')
            if password_confirm == password:
                break
            else:
                print('Passwords do not match... Try again...')
        role = raw_input('Role: ').strip()
        # create role if needed
        if not db.roles.find_one(schema.role(role)):
            utils.create_role(role)
        utils.create_user(username=username, email=email, password=password, \
            role=role, enabled=True)
        print('User created/updated successfully...')
    except KeyboardInterrupt:
        pass
Beispiel #5
0
def create_user():
    db = get_db_connection()
    try:
        username = raw_input('Username: '******'Email: ').strip()
        while True:
            password = getpass('Password: '******' (confirm): ')
            if password_confirm == password:
                break
            else:
                print('Passwords do not match... Try again...')
        role = raw_input('Role: ').strip()
        # create role if needed
        if not db.roles.find_one(schema.role(role)):
            utils.create_role(role)
        utils.create_user(username=username, email=email, password=password, \
            role=role, enabled=True)
        print('User created/updated successfully...')
    except KeyboardInterrupt:
        pass
Beispiel #6
0
def delete_role(rolename=None):
    if not rolename:
        raise NameError('You must specify a rolename')
    db = application.get_db_connection()
    db.roles.remove(schema.role(rolename=rolename))
    return True
Beispiel #7
0
def delete_role(rolename=None):
    if not rolename:
        raise NameError('You must specify a rolename')
    db = application.get_db_connection()
    db.roles.remove(schema.role(rolename=rolename))
    return True