Beispiel #1
0
def sign_up_completed():
    """
    This function forces the user to re-login to make user their details are in order.
    It will also clean up any left overs that may have been left in the session cookie.
    :return:
    """
    form = siteForms.LoginConfirm(request.form)
    if request.method == "POST":
        data, confirm = login_action(form)

        if confirm:

            company_schema = sql_functions.get_company_schema(data[2])
            person_ID = sql_functions.get_company_person_ID(data[0], company_schema)

            login_details = {
                "user_ID": data[0],
                "company_ID": data[2],
                "company_schema": company_schema,
                "person_ID": person_ID,
            }
            session["manger"] = (data[0], data[3])

            session.clear()
            session["login_details"] = login_details
            session["logged_in"] = True

            flash("Logged in successfully.")
            return redirect("/home/")

        else:
            flash("Login details did not match.")

    return render_template("SetUp/signUpCompleted.html", form=form)
Beispiel #2
0
def login():
    # FIXME the page fails if the details do not matchup
    session.clear()
    form = siteForms.LoginConfirm(request.form)
    if request.method == "POST":
        data, confirm, = login_action(form)

        if confirm:

            company_schema = sql_functions.get_company_schema(data[2])
            person_ID = sql_functions.get_company_person_ID(data[0], company_schema)

            login_details = {
                "user_ID": data[0],
                "company_ID": data[2],
                "company_schema": company_schema,
                "person_ID": person_ID,
            }
            session["manger"] = (data[0], data[3])
            user = User(login_details)

            session.clear()
            session["login_details"] = login_details
            session["logged_in"] = True

            flash("Logged in successfully.")
            return redirect("/home/")

        else:
            flash("Login details did not match.")
            return render_template("Login/login.html", form=form)

    return render_template("Login/login.html", form=form)