Beispiel #1
0
 def wrapper(*args, **kwargs):
     result = fn(*args, **kwargs)
     if isinstance(result, dict) and result.get("access_token") is not None:
         access_token = result["access_token"]
         res = decode_token(access_token)
         if res:
             identity = res["identity"]
             access_jti = res["jti"]
             redis_0.set("soco:access_token:{}".format(identity),
                         access_jti)
     return result
Beispiel #2
0
    def get(self):
        """获取图片验证码
          ---
          tags:
            - 登录、注册
          responses:
            200:
              description: A list of colors (may be filtered by palette)
              examples:
                response: {"data": {"verify_code_image": "base64图片", "uuid": "x*32"}, "message": "发送成功"}
        """
        valid_code_object = VerifyCodeImg()
        valid_code_bytes, valid_code_string = valid_code_object.get_verify_code_image()
        valid_code_base64_string = base64.b64encode(valid_code_bytes).decode()
        unique_string = generate_uuid()
        redis_0.set("verify_code:" + unique_string, valid_code_string, ex=Conf.get("VERIFY_CODE_EXPIRE", 180))

        return json_response(data={
            "verify_code_image": valid_code_base64_string,
            "uuid": unique_string
        }, message="成功")
Beispiel #3
0
def add_access_token_to_redis(user_id, access_token):
    access_jti = get_jti(encoded_token=access_token)
    redis_0.set("soco:access_token:{}".format(user_id), access_jti)