Beispiel #1
0
def get_user_info():
    token_args = {
        'token': Str(required=True),
    }
    args = args_parser.parse(token_args)
    token = args.get('token')
    user = User.get_user_by_token(token)
    if user:
        return user.to_dict()
    return
Beispiel #2
0
def save_blog():
    blog_args = {
        'topic': Str(required=True),
        'genre': Str(required=True),
        'content': Str(required=True)
    }
    args = args_parser.parse(blog_args)
    topic = args.get('topic')
    genre = args.get('genre')
    content = args.get('content')
    Blog.add_blog(topic, genre, content)
    return {'msg': u'博客添加成功'}
Beispiel #3
0
def register():
    register_args = {
        'account': Str(required=True),
        'password': Str(required=True)
    }
    args = args_parser.parse(register_args)
    account = args.get('account')
    password = args.get('password')
    user = User.get_account(account)
    if user:
        return {'msg': u'账号已存在'}
    User.add(account, password)
    return {'msg': u'账号注册成功'}
Beispiel #4
0
def login():
    login_args = {
        'account': Str(required=True),
        'password': Str(required=True)
    }
    args = args_parser.parse(login_args)
    account = args.get('account')
    password = args.get('password')
    user = User.get(account)
    if user:
        verify = user.verify_password(password)
        if verify:
            token = user.generate_auth_token()
            return {'msg': u'登录成功', 'token': token}
    return {'msg': u'账号或密码错误'}
Beispiel #5
0
def test_ping():
    test_args = {'name': Str(required=True), 'password': Int(required=True)}
    args = args_parser.parse(test_args)
    return args