Exemple #1
0
def auth_login(phone, passwd):
    '''
    [
        {"name": "phone", "required": 1, "check": "string", "description": "手机号"},
        {"name": "passwd", "required": 1, "check": "string", "description": "密码"}
    ]
    '''
    account = Account.query.filter_by(phone=phone, passwd=Account.md5_passwd(passwd)).first()
    if not account:
        return custom(-1, "账户名或密码错误")
    account.app_token = uuid.uuid4().hex

    def callback(param):
        return param.to_json()

    return commit_callback(callback=callback, param=(account, ))
Exemple #2
0
def auth_register(phone, passwd, name):
    '''
    [
        {"name": "phone", "required": 1, "check": "string", "description": "手机号"},
        {"name": "passwd", "required": 1, "check": "string", "description": "密码"},
        {"name": "name", "required": 1, "check": "string", "description": "姓名"}
    ]
    '''
    # 是否注册过
    account = Account.query.filter_by(phone=phone).first()
    if account:
        return custom(-1, "该账号已注册")
    account = Account(
        phone=phone,
        passwd=Account.md5_passwd(passwd),
        name=name
    )
    db.session.add(account)

    def callback(param):
        return param.to_json()

    return commit_callback(callback=callback, param=(account, ))