示例#1
0
def login_post():
    vm = LoginViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    # todo: log in browser as session
    resp = flask.redirect("/")
    cookie.set_auth(resp, str(vm.user.id))

    return resp
def login_post():
    vm = LoginViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    user = user_service.login_user(vm.email, vm.password)
    if not user:
        vm.error = "The account does not exist or the password is wrong."
        return vm.to_dict()

    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)

    return resp
示例#3
0
def loginadmin():
    if flask.request.method == "POST":
        vm = LoginViewModel()
        vm.validate()
        if vm.error:
            return vm.convert_to_dict()

        admin = admin_service.login_admin_self(vm.email, vm.password)
        if not admin:
            vm.error = "The account does not exist or the password is wrong (admin)."
            return vm.convert_to_dict()

        if admin:
            resp = flask.redirect('/admin')
            cookie_auth.set_auth(resp, admin.id)
            login_user(admin_service.check_admin_or_user(admin.id))

            return resp
def login_post():
    vm = LoginViewModel()
    vm.validate()

    if vm.error:
        return render_template("account/login.html", error=vm.error)

    user = user_service.login_user(vm.username, vm.password)
    if not user:
        return render_template("account/login.html",
                               username=vm.username,
                               error="The account does not exist or the "
                               "password is wrong.")

    # Validate the user
    login_user(user)

    return redirect("/account")