def login(): if request.method == "GET": if checkSession() is False: return render_template("auth/signin.html") else: return redirect(url_for("home")) elif request.method == "POST": form = LoginForm(request.form) if form.validate(): email = form.email.data if email.count("@") != 0: flash(u"L'email entré est incorrect", "error_login") return render_template("auth/signin.html") email += "@insa-lyon.fr" password = form.password.data objeet, error = loginmouv(email, password) if objeet is None: if error == 1: problem = u"L'utilisateur " + email + u"n'existe pas." flash(problem, "error_login") page = "auth/signin.html" elif error == 2: problem = u"Connexion refusé" flash(problem, "error_login") page = "auth/signin.html" else: saveInSession(objeet.id) problem = u"Connexion ok" flash(problem, "error_login") return redirect(url_for("personnel")) return render_template(page, form=form) else: problem = u"Connexion refusé" flash(problem, "error_login") return render_template("auth/signin.html")
def logout(): if request.method == "GET": if checkSession() is True: clearSession() return redirect(url_for("home"))