Exemplo n.º 1
0
def update_user_sns(id):
    user = userService.get_user_by_id(id)
    if user is None:
        return Restful.bad_request('用户ID: %s 不存在' % id)

    userService.spider_user_sns(user)
    return Restful.ok()
Exemplo n.º 2
0
def get_user(id):
    user = userService.get_user_by_id(id)
    if user is None:
        return Restful.bad_request('用户ID: %s 不存在' % id)

    user = safe_model_to_json(enrich_user(user))
    return Restful.ok(user)
Exemplo n.º 3
0
def get_user_list():
    fuzzy = request.args.get('fuzzy', type=str)
    order = request.args.get('order', type=str)
    page, paginate_by = get_request_page_args(request)
    paginate = Paginate(userService.get_user_list(fuzzy=fuzzy), '/user', page, paginate_by)

    return Restful.ok(paginate.to_json())    
Exemplo n.º 4
0
def get_token():
    if g.token_used:
        return Restful.forbidden('请使用用户名和密码')

    return Restful.ok({
            'userId': g.current_user.id,
            'username': g.current_user.username,
            'avatar': g.current_user.avatar,
            'slogan': g.current_user.slogan,
            'token': userService.generate_auth_token(g.current_user.id, 3600*24), 
            'expiration': 3600*24
        })    
Exemplo n.º 5
0
def logout():
    return Restful.ok()
Exemplo n.º 6
0
def modify_user(id):
    try:
        user = userService.modify_user_profile(id, request.json)
        return Restful.ok(user.to_json())
    except ServiceError, e:
        return Restful.bad_request(e.message)