La version 5 de Planète Casio. Regroupe le forum, les programmes, les tutoriel, les sprites et tous les autres outils développés par nos soins.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.9 KiB

from flask import render_template, flash, redirect, url_for, request
from flask_login import login_user, logout_user, current_user, login_required
from werkzeug.urls import url_parse
from app import app, db
from app.forms import LoginForm, RegistrationForm, UpdateAccountForm
from app.models.users import Member
def index():
login_form = LoginForm()
return render_template('index.html', login_form=login_form)
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'GET':
return redirect(url_for('index'))
login_form = LoginForm()
if form.validate_on_submit():
member = Member.query.filter_by(
if member is None or not member.check_password(
flash('Pseudo ou mot de passe invalide', 'error')
return redirect(request.referrer)
flash('Connexion réussie', 'info')
return redirect(request.referrer)
def logout():
flash('Déconnexion réussie', 'info')
return redirect(url_for('index'))
@app.route('/account', methods=['GET', 'POST'])
def account():
if not current_user.is_authenticated:
flash('Veuillez vous authentifier', 'warning')
return redirect(url_for('index'))
login_form = LoginForm()
form2 = UpdateAccountForm()
if request.method == "POST":
if form2.validate_on_submit():
email =,
password =,
signature =,
biography =,
birthday =,
receive_newsletter =
flash('Modifications effectuées', 'ok')
flash('Erreur lors de la modification', 'error')
return render_template('account.html', login_form=login_form, form2=form2)
@app.route('/register', methods=['GET', 'POST'])
def register():
if current_user.is_authenticated:
return redirect(url_for('index'))
login_form = LoginForm()
form2 = RegistrationForm()
if form2.validate_on_submit():
member = Member(,,
member.biography = ""
member.signature = ""
flash('Inscription réussie', 'ok')
return redirect(url_for('validation'))
return render_template('register.html', title='Register', login_form=login_form, form2=form2)
def validation():
if current_user.is_authenticated :
return redirect(url_for('index'))
login_form = LoginForm()
return render_template('validation.html', login_form=login_form)