Ejemplo n.º 1
0
    def post(self):
        post = request.form
        tel = post.get("tel")
        if not tel:
            return success(res={'r': 1, 'error_code': 4006, 'msg': '手机号不能为空'})

        if not AdminAccount.objects(tel=tel):
            return success(res={'r': 1, 'error_code': 4006, 'msg': '用户不存在'})

        key = model.CHECKCODE_KEY.format(tel=tel)
        code = cache.get(key)
        if not code:
            code = random.randint(100000, 999999)
            cache.incr(key, code)
            cache.expire(key, 300)

        if config.get("DEBUG"):
            print code, "CODEEE"
            ret = True
        else:
            ret = alidayu_tool.send_code(phone=tel, num=str(code))

        if ret:
            return success(res={})
        else:
            return success(res={'error_code': 4001, 'msg': u'验证码发送失败'})
Ejemplo n.º 2
0
 def cache_by_key(cls, key, ids):
     """给内部用"""
     cache.delete(key)
     cache.rpush(key, *ids)
     cache.expire(key, TIMEOUT)