def send_migu_code(): """发送短信验证码 (GET|POST) :uri: /migu/sms_code :param phone: 手机号 :param action: (注册:reg 重置:reset 升级:up) :returns: {'sessionid': string} """ params = request.values phone = params.get('phone', None) action = params.get('action', None) if not phone: return error.InvalidArguments # 如果是注册验证码,提前判断手机号是否已存在 ret = Migu.center_check_account(phone, const.CENTER_ACCOUNT_PHONE) if isinstance(ret, error.ApiError): return ret if action == 'reg' and not ret: return error.UserExists ret = Migu.center_sms_code(phone, action) if isinstance(ret, error.ApiError): return ret return {'sessionid': ret}
def migu_verify_phone(): """手机号码验证 (GET|POST) :uri: /migu/verify_phone :param phone: 手机号 :returns: {} """ params = request.values.to_dict() phone = params.get('phone', None) if not phone: return error.InvalidArguments ret = Migu.center_check_account(phone, const.CENTER_ACCOUNT_PHONE) if isinstance(ret, error.ApiError): return ret elif not ret: return error.UserExists("手机号已被注册") return {}