Example #1
0
def get_user_info(username, roles):
    user_query = db((db.user.username == username) 
             & (db.user.id == db.user_membership.user_id)
             & (db.user_membership.group_id == db.user_group.id)
             & (db.user_group.role.belongs(roles)))
    user = user_query.select().first()
    # If user not present in DB
    if not user:
        if current.auth_type == 'ldap':
            user_info = fetch_ldap_user(username)
            if user_info:
                if [obj for obj in roles if obj in user_info['roles']]:
                    create_or_update_user(user_info, False)
                    user = user_query.select().first()
    
    if user:
        return (user.user.id, (user.user.first_name + ' ' + user.user.last_name))	
Example #2
0
def get_user_info(username, roles=[USER, FACULTY, ORGADMIN, ADMIN]):

    user_query = db((db.user.username == username) 
             & (db.user.id == db.user_membership.user_id)
             & (db.user_membership.group_id == db.user_group.id)
             & (db.user_group.role.belongs(roles)))
    
    user = user_query.select(db.user.ALL).first()
    
    # If user not present in DB
    if not user:
        if current.auth_type == AUTH_TYPE_LDAP :
            user_info = fetch_ldap_user(username)
            if user_info:
                if [obj for obj in roles if obj in user_info['roles']]:
                    create_or_update_user(user_info, False)
                    user = user_query.select(db.user.ALL).first()
    
    if user:
        if is_moderator() | (user['organisation_id'] == auth.user.organisation_id):
            return (user['id'], (user['first_name'] + ' ' + user['last_name']))
Example #3
0
def get_user_info(username, roles=[USER, FACULTY, ORGADMIN, ADMIN]):

    user_query = db((db.user.username == username) 
             & (db.user.id == db.user_membership.user_id)
             & (db.user_membership.group_id == db.user_group.id)
             & (db.user_group.role.belongs(roles)))
    
    user = user_query.select(db.user.ALL).first()
    
    # If user not present in DB
    if not user:
        if current.auth_type == AUTH_TYPE_LDAP :
            user_info = fetch_ldap_user(username)
            if user_info:
                if [obj for obj in roles if obj in user_info['roles']]:
                    create_or_update_user(user_info, False)
                    user = user_query.select(db.user.ALL).first()
    
    if user:
        if is_moderator() | (user['organisation_id'] == auth.user.organisation_id):
            return (user['id'], (user['first_name'] + ' ' + user['last_name']))