old_contents: from flask import render_template, redirect, request, url_for, flash
  from flask_login import login_user, logout_user, login_required
  from . import auth
  from .forms.authforms import LoginForm, RegisterForm
  from app.models import User
  from app import db
  
  @auth.route('/login', methods=['GET', 'POST'])
  def login():
      form = LoginForm()
      if form.validate_on_submit():
          user = User.query.filter_by(username=form.username.data).first()
          if user is not None and user.check_password(form.password.data):
              login_user(user, remember=form.remember.data)
              flash('Connexion réussie!', 'success')
              return redirect(url_for('main.index'))
          flash('Mauvaises informations de connexion.', 'danger')
      return render_template('auth/login.html', form=form)
  
  @auth.route('/register', methods=['GET', 'POST'])
  def register():
      form = RegisterForm()
      if form.validate_on_submit():
          user = User(username=form.username.data, name=form.name.data,
                      email=form.email.data, password=form.password.data)
          db.session.add(user)
          db.session.commit()
          flash('Compte créé! Vous pouvez maintenant vous connecter.', 'success')
          return redirect(url_for('auth.login'))
      return render_template('auth/register.html', form=form)
  
  @auth.route('/logout')
  @login_required
  def logout():
      logout_user()
      flash('Déconnexion réussie.', 'success')
      return redirect(url_for('main.index'))
  
new_contents: from flask import render_template, redirect, request, url_for, flash
  from flask_login import login_user, logout_user, login_required
  from . import auth
  from .forms.authforms import LoginForm, RegisterForm
  from app.models import User
  from app import db
  
  @auth.route('/login', methods=['GET', 'POST'])
  def login():
      form = LoginForm()
      if form.validate_on_submit():
          user = User.query.filter_by(username=form.username.data).first()
          if user is not None and user.check_password(form.password.data):
              from datetime import datetime
              user.last_visit = datetime.utcnow
              login_user(user, remember=form.remember.data)
              db.session.commit()
              flash('Connexion réussie!', 'success')
              return redirect(url_for('main.index'))
          flash('Mauvaises informations de connexion.', 'danger')
      return render_template('auth/login.html', form=form)
  
  @auth.route('/register', methods=['GET', 'POST'])
  def register():
      form = RegisterForm()
      if form.validate_on_submit():
          user = User(username=form.username.data, name=form.name.data,
                      email=form.email.data, password=form.password.data)
          db.session.add(user)
          db.session.commit()
          flash('Compte créé! Vous pouvez maintenant vous connecter.', 'success')
          return redirect(url_for('auth.login'))
      return render_template('auth/register.html', form=form)
  
  @auth.route('/logout')
  @login_required
  def logout():
      logout_user()
      flash('Déconnexion réussie.', 'success')
      return redirect(url_for('main.index'))
  
subject: update user account with last login time when loggin in