Esempio n. 1
0
def misc_feedback():
    res = dict(msg=None, success=False)
    if request.method == "POST":
        point = request.form.get("point")
        content = request.form.get("content")
        email = request.form.get("email")
        check = True
        if point and content:
            if email:
                if not email_check(email):
                    check = False
                    res.update(msg="Bad mailbox format")
        else:
            check = False
            res.update(msg="There are invalid parameters")
        if check:
            # 初始化邮箱发送服务
            sendmail = SendMail()
            result = sendmail.SendMessage(
                to_addr=SYSTEM["EMAIL"],
                subject=u"SaintIC Passport 用户反馈: %s" % point,
                formatType="html",
                message=u"用户预留邮箱:%s<br/>用户反馈内容:<br/>%s" % (email, content))
            res.update(result)
    return jsonify(dfr(res))
Esempio n. 2
0
def misc_sendVcode():
    """发送验证码:邮箱、手机"""
    res = dict(msg=None, success=False)
    account = request.form.get("account")
    scene = request.form.get("scene") or request.args.get("scene") or "signUp"
    scenemap = dict(signUp=u"注册", bindLauth=u"绑定本地化账号", forgot=u"忘记密码")
    if email_check(account):
        # 生成验证码,校验的话,libs.auth.Authentication类中`__check_sendVcode`方法
        email = account
        key = "passport:vcode:{}:{}".format(scene, email)
        try:
            hasKey = g.redis.exists(key)
        except Exception, e:
            logger.error(e, exc_info=True)
            res.update(msg="System is abnormal")
        else:
            if hasKey:
                res.update(msg="Have sent the verification code, please check the mailbox")
            else:
                # 初始化邮箱发送服务
                sendmail = SendMail()
                vcode = generate_verification_code()
                result = sendmail.SendMessage(to_addr=email, subject=u"SaintIC Passport %s 验证码" %scenemap[scene], formatType="html", message=email_tpl % (email, scenemap[scene], vcode))
                if result["success"]:
                    try:
                        g.redis.set(key, vcode)
                        g.redis.expire(key, 300)
                    except Exception, e:
                        logger.error(e, exc_info=True)
                        res.update(msg="System is abnormal")
                    else:
                        res.update(msg="Sent verification code, valid for 300 seconds", success=True)
                else:
Esempio n. 3
0
    :copyright: (c) 2017 by staugur.
    :license: MIT, see LICENSE for more details.
"""
import json
from config import VAPTCHA
from utils.send_email_msg import SendMail
from utils.web import email_tpl, login_required, anonymous_required, dfr, set_cookie
from utils.tool import logger, generate_verification_code, email_check, phone_check
from libs.auth import Authentication
from vaptchasdk import vaptcha as VaptchaApi
from flask import Blueprint, request, render_template, jsonify, g, abort, redirect, url_for, flash, make_response

#初始化前台蓝图
FrontBlueprint = Blueprint("front", __name__)
#初始化邮箱发送服务
sendmail = SendMail()
#初始化手势验证码服务
vaptcha = VaptchaApi(VAPTCHA["vid"], VAPTCHA["key"])


@FrontBlueprint.route('/')
def index():
    #首页
    return render_template("index.html")


@FrontBlueprint.route('/user')
def userhome():
    return render_template("user/index.html")