def user_login(): form = LoginForm() if form.validate_on_submit(): user = current_users.get_user(form.name.data) login_user(user) user.set('authenticated', True) flash('Login successful.', 'success') return redirect(request.args.get("next") or url_for('wiki.index')) return render_template('login.html', form=form)
def admin(): form = LoginForm() flash('Please log in to view this page', 'warning') with open('./user/users.json', 'r') as json_file: users = json.load(json_file) if form.validate_on_submit(): user = current_users.get_user(form.name.data) if user.get("roles")[0] == 'admin': return render_template('admin.html', permission=True, users=users) else: return render_template('admin.html', permission=False, users=users) return render_template('login.html', form=form)
def user_login(): if current_user.is_active: return redirect(request.args.get("next") or url_for('wiki.home')) form = LoginForm() if form.is_submitted(): if not form.validate_name(form.name): flash("That user does not exist.", 'error') else: if not form.validate_password(form.password): flash("Incorrect password.", 'error') else: user = current_users.get_user(form.name.data) login_user(user) user.set('authenticated', True) user.set('active', True) flash('Login successful.', 'success') return redirect( request.args.get("next") or url_for('wiki.home')) return render_template('login.html', form=form)