예제 #1
0
def sendMail():
    email = request.args.get("email")
    isEmail = User.query.filter(User.email == email, User.is_ok == 1).first()

    if not isEmail:
        random_sample = random.sample('1234567890abcdefghijklmnopqrstuvwxyz', 4)
        print(random_sample)
        random_sample = ''.join(random_sample)
        print(random_sample)
        redis_cache.set("random_sample", str(random_sample))
        msg = Message(subject="南阳理工学院二手交易平台动态码", recipients=[email])
        msg.html = "<b><img src='http://pgfgqbd3k.bkt.clouddn.com/loginUI.png' " \
                   "style='width:260px'></b><br><b>南阳理工学院二手交易平台注册动态码:" \
                   "<font color='red'>" + random_sample + "</font><b>"
        send_mail.send(msg)
        return jsonify({"msg": "", 'status': "200"})
    else:
        return jsonify({"msg": "检测到该邮箱已经被注册,一个邮箱只有一个南工二手交易平台账号", 'status': "500"})
예제 #2
0
def sendMail():
    email = request.args.get("email")
    isEmail = User.query.filter(User.email == email, User.is_ok == 1).first()

    if not isEmail:
        random_sample = random.sample('1234567890abcdefghijklmnopqrstuvwxyz',
                                      4)
        random_sample = ''.join(random_sample)
        redis_cache.set(email, str(random_sample))
        msg = Message(subject="中原工学院在线交易平台动态码", recipients=[email])
        msg.html = "<b><img src='https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3282424091,3209377413&fm=26&gp=0.jpg' " \
                   "style='width:260px'></b><br><b>中原工工学院在线交易平台注册动态码:" \
                   "<font color='red'>" + random_sample + "</font><b>"
        send_mail.send(msg)
        return jsonify({"msg": "", 'status': "200"})
    else:
        return jsonify({
            "msg": "检测到该邮箱已经被注册,一个邮箱只有一个中工在线交易平台账号",
            'status': "500"
        })
예제 #3
0
def resetPassword():
    email = request.args.get('email')
    name = request.args.get('name')
    user = User.query.filter(User.email == email).first()
    if user is None:
        return jsonify({'status': 500, 'msg': '此邮箱无注册记录'})
    else:
        if user.username != name:
            return jsonify({"msg": "主人姓名不对呦~~~", 'status': "500"})
        else:
            random_sample = random.sample('1234567890abcdefghijklmnopqrstuvwxyz', 6)
            random_sample = ''.join(random_sample)
            user.password = generate_password_hash(random_sample)
            db.session.commit()
            msg = Message(subject="南阳理工学院二手交易平台找回密码", recipients=[email])
            msg.html = "<b><img src='http://pgfgqbd3k.bkt.clouddn.com/loginUI.png' " \
                       "style='width:260px'></b><br><b>南阳理工学院二手平台重置你的密码为:" \
                       "<font color='red'>" + random_sample + "</font>,建议登录之后修改密码,谢谢你的使用!<b>"
            send_mail.send(msg)
            return jsonify({"msg": "", 'status': "200"})
예제 #4
0
def resetPassword():
    email = request.args.get('email')
    name = request.args.get('name')
    user = User.query.filter(User.email == email).first()
    if user is None:
        return jsonify({'status': 500, 'msg': '此邮箱无注册记录'})
    else:
        if user.username != name:
            return jsonify({"msg": "主人姓名不对呦~~~", 'status': "500"})
        else:
            random_sample = random.sample(
                '1234567890abcdefghijklmnopqrstuvwxyz', 6)
            random_sample = ''.join(random_sample)
            user.password = generate_password_hash(random_sample)
            db.session.commit()
            msg = Message(subject="中原工在线商城找回密码", recipients=[email])
            msg.html = "<b><img src='https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3282424091,3209377413&fm=26&gp=0.jpg" \
                       "style='width:260px'></b><br><b>中原工在线商城重置你的密码为:" \
                       "<font color='red'>" + random_sample + "</font>,建议登录之后修改密码,谢谢你的使用!<b>"
            send_mail.send(msg)
            return jsonify({"msg": "", 'status': "200"})