示例#1
0
文件: sms.py 项目: hiyouth/herovii
def send_sms_code():
    """ 发送验证码短信
    发送一条验证码短信,默认使用bmob服务发送
    :POST:
    {'phone_number':'1869999xxxx'}
    :return:
        返回操作是否成功相关信息
    """
    bmob = BMOB()
    form = PhoneNumberForm.create_api_form()
    phone_number = form.phone_number.data
    status, body = bmob.send_sms_code(phone_number)
    if status == 200:
        return success_json(), 201
    else:
        j = json.loads(body)
        raise UnknownError(j['error'], error_code=None)
示例#2
0
文件: user.py 项目: hiyouth/herovii
def create_by_mobile():
    """ 添加一个机构用户
    调用此接口需要先调用'/v1/sms/verify' 接口,以获得短信验证码
    :POST:
        {'phone_number':'18699998888', 'sms_code':'876876', 'password':'******'}
    :return:
    """
    bmob = BMOB()
    form = RegisterByMobileForm.create_api_form()
    phone_number = form.phone_number.data
    sms_code = form.sms_code.data
    status, body = bmob.verify_sms_code(phone_number, sms_code)
    if status == 200:
        user = account.register_by_mobile(phone_number, sms_code)
        return jsonify(user), 201
    else:
        j = json.loads(body)
        raise UnknownError(j['error'], error_code=None)
示例#3
0
文件: user.py 项目: hiyouth/herovii
def find_password():
    """ 重置/找回密码
        调用此接口需要先调用'/v1/sms/verify' 接口,以获得短信验证码
    :PUT:
        {"phone_number":'18699998888', "sms_code":'876876', "password":'******'}
    :return:
    """
    bmob = BMOB()
    form = RegisterByMobileForm.create_api_form()
    mobile = form.phone_number.data
    password = form.password.data
    sms_code = form.sms_code.data
    status, body = bmob.verify_sms_code(mobile, sms_code)
    if status == 200:
        account.reset_password_by_mobile(mobile, password)
        return success_json(), 202
    else:
        j = json.loads(body)
        raise UnknownError(j['error'], error_code=None)