示例#1
0
    def save_wechat_id(self):
        # 验证验证码是否存在
        redis = Redis()

        if redis_store.exists(self.auth_key.data):
            current_user.wechat_id = redis_store.get(self.auth_key.data)
            current_user.save()
        else:
            flash(u'验证码错误', 'danger')
示例#2
0
    def save_wechat_id(self):
        # 验证验证码是否存在
        redis = Redis()


        if redis_store.exists(self.auth_key.data):
            current_user.wechat_id = redis_store.get(self.auth_key.data)
            current_user.save()
        else:
            flash(u'验证码错误', 'danger')
示例#3
0
def auth_key(length=6):
    """
    获取随机验证码
    :param length: 验证码长度
    :return: 0-9长度为length(默认6)的0-9的字符串 例如:'0324'
    """
    while(True):
        s = ''
        for i in range(length):
            s += str(randint(0, 9))
        if not redis_store.exists(s):
            break
    return s
示例#4
0
def auth_key(length=6):
    """
    获取随机验证码
    :param length: 验证码长度
    :return: 0-9长度为length(默认6)的0-9的字符串 例如:'0324'
    """
    while (True):
        s = ''
        for i in range(length):
            s += str(randint(0, 9))
        if not redis_store.exists(s):
            break
    return s