def logout(): if 'user' in session: user = session['user'] session.pop('user') elif 'admin' in session: user = session['admin'] session.pop('admin') Log.insert(user_id=user['id'], action='LOGOUT').execute() return redirect(url_for('main.login'))
def login(): form = LoginForm(request.form) if form.validate_on_submit(): user = User.get_or_none(User.email_address == form.email_address.data) if user and check_password_hash(user.password, form.password.data): Log.insert(user_id=user.id, action='LOGIN').execute() session['user'] = model_to_dict(user) flash("Welcome back, {}!".format(user.first_name)) return redirect(request.args.get('next', url_for('main.index'))) return render_template('main/login.html', form=form)
def logout(): Log.insert(user_id=session['user']['id'], action='LOGOUT').execute() session.pop('user') return redirect(url_for('main.login'))