Exemplo n.º 1
0
Arquivo: auth.py Projeto: DianQ/MyCode
def authenticate_admin(email='', password=''):
    """
    """
    member = models.UserDAO.get_by_email(email)
    if member is None:
        return None

    security_pass = helpers.encode_pass(password)
    if security_pass != member.passhash:
        return None

    return member.id
Exemplo n.º 2
0
Arquivo: base.py Projeto: DianQ/MyCode
def login():
    form = forms.LoginForm(csrf_enabled=False)

    # post
    if form.validate_on_submit():
        email = form.email.data
        password = form.password.data
        security_pass = helpers.encode_pass(password)
        member = user.get_user_by_email(email)

        if member is None:
            flash("用户不存在")
        elif security_pass != member.password:
            flash("用户名或密码错误")
        flash("登陆成功!")

    return render_template("login.html", title=u"登入", form=form)
Exemplo n.º 3
0
Arquivo: user.py Projeto: DianQ/MyCode
def create_admin(email, password, name):
    security_pass = helpers.encode_pass(password)
    result = models.UserDAO.new_admin(email, security_pass, name)
    return result