Ejemplo n.º 1
0
 async def reg_code_cleanup(cls, email):
     email = email.encode('utf-8')
     pipe = redis.pipeline()
     pipe.delete(RK_USER_REG_CODE_BY_EMAIL % email)
     pipe.delete(RK_USER_REG_CODE_AVAILABLE_TIMES_BY_EMAIL % email)
     pipe.delete(RK_USER_REG_PASSWORD % email)
     await pipe.execute()
Ejemplo n.º 2
0
 async def gen_reg_code_by_email(cls, email: str, password: str):
     t = int(time.time())
     code = os.urandom(8)
     email = email.encode('utf-8')
     pipe = redis.pipeline()
     pipe.set(RK_USER_REG_CODE_AVAILABLE_TIMES_BY_EMAIL % email,
              config.USER_REG_CODE_AVAILABLE_TIMES_BY_EMAIL,
              expire=config.USER_REG_CODE_EXPIRE)
     pipe.set(RK_USER_REG_CODE_BY_EMAIL % email, code, expire=config.USER_REG_CODE_EXPIRE)
     pipe.set(RK_USER_REG_PASSWORD % email, password, expire=config.USER_REG_CODE_EXPIRE)
     await pipe.execute()
     return code
Ejemplo n.º 3
0
 async def gen_activation_code(self) -> bytes:
     """
     生成一个账户激活码
     :return:
     """
     t = int(time.time())
     code = os.urandom(8)
     pipe = redis.pipeline()
     pipe.set(RK_USER_LAST_REQUEST_ACTCODE_BY_USER_ID % self.id, t)
     pipe.set(RK_USER_ACTCODE_BY_USER_ID % self.id,
              code,
              expire=config.USER_ACTCODE_EXPIRE)
     await pipe.execute()
     return code