def validCode(cls,username,code): cdinfo = SecurityHandler.loadCode(code,keepAlive=True) return cdinfo and cdinfo["username"]==username
def generateCode(cls,username): cd = "" while SecurityHandler.exists(cd) or cd=="": cd = utility.generateCode(6) SecurityHandler.bindCode(cd,info = dict(username=username),expire= 24*60) return cd