Example #1
0
def get_current_user(request):
    user_id = request.session.get('user_id', None)
    user = None
    if user_id is not None:
        user = User.by_id(user_id)
    return user if user else None
Example #2
0
def user_add_role_lib(userid, roleid):
    user = User.by_id(userid)
    role = Role.by_id(roleid)
    if user and role:
        role.users.add(user)