def change_user(id): if not current_user.is_admin and current_user.id != id: flash("Je bent geen admin", 'danger') return redirect('/') user_to_change = User.query.get_or_404(id) user_to_change_prediction = Prediction.query.filter_by(user_id=id).first() form = LoginForm(request.form, username=user_to_change.username, pin=user_to_change.pin) if form.validate_on_submit(): found_user = User.query.filter_by(username=form.username.data).first() if not found_user or found_user.id == id: user_to_change.username = form.username.data user_to_change_prediction.username = form.username.data user_to_change.pin = form.pin.data db.session.commit() flash('Opgeslagen', 'success') if current_user.is_admin: return redirect(url_for('users.admin')) else: return redirect(url_for('users.index')) else: flash('Die gebruikersnaam bestaat al', 'danger') return render_template('login.html', form=form, change=True, title='Gebruiker')
def login(): form = LoginForm() if form.validate_on_submit(): user = Users.query.filter_by(username=form.username.data).first() if user is not None: #check ob Eintrag in Datenbank vorhanden if user.check_password(form.password.data) and user is not None: #wenn ja, dann check passwort login_user(user) logging.debug(f"{user} logged in") flash("Login erfolgreich!", category='success') next = request.args.get("next") if next == None or next[0] == "/": next = url_for("bot.index") return redirect(next) else: flash("Passwort falsch!", category='danger') logging.debug(f"Passwort falsch!") else: flash("So jemand kenne ich hier nicht...", category='danger') logging.debug(f"Unautorisierter Zugriff!") return render_template("login.html", form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('main.index')) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember=form.remember.data) next_page = request.args.get('next') return redirect(next_page) if next_page else redirect( url_for('main.index')) else: flash('Login Unsuccessful. Please check email and password', 'danger') return render_template('users/login.html', title='Login', form=form)
def login(): if current_user.is_authenticated: flash("Je bent al ingelogd.", 'success') return redirect(url_for('users.index')) form = LoginForm() if form.validate_on_submit(): found_user = User.query.filter_by(username=form.username.data).first() if found_user and found_user.pin == form.pin.data: login_user(found_user) flash(Markup( f'Ingelogd als <strong>{form.username.data}</strong>'), 'success') next_page = request.args.get('next') return redirect(next_page) if next_page else redirect(url_for('users.index')) else: flash("Vul de juiste gegevens in.", 'danger') return render_template('login.html', form=form, title='Login')
def login(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember=form.remember.data) next_page = request.args.get('next') flash(get_response_message('users', 'login', 'success', ''), 'success') return redirect(next_page) if next_page else redirect( url_for('main.home')) else: flash(get_response_message('users', 'login', 'failure', ''), 'danger') return render_template('login.html', title='Login', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for("core.index")) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user is None or not user.check_password(form.password.data): flash("Invalid username or password") return redirect(url_for("users.login")) login_user(user, remember=form.remember_me.data) next_page = request.args.get("next") if not next_page or url_parse(next_page).netloc != "": next_page = url_for("core.index") return redirect(next_page) return render_template("login.html", title="Sign In", form=form)
def login(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user.check_password(form.password.data) and user is not None: login_user(user) flash('Log in success!') next = request.args.get('next') if next == None or not next[0] == '/': next = url_for('core.index') return redirect(next) return render_template('login.html', form=form)
def login(): """Log user in""" if current_user.is_authenticated: return redirect(url_for('main.index')) form = LoginForm() if form.validate_on_submit(): # Query database for username user = User.query.filter_by(username=form.username.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember=form.remember.data) # Set status to online user.status = 1 db.session.commit() next_page = request.args.get('next') return redirect(next_page) if next_page else redirect( url_for("main.index")) else: flash('Login Unsuccesful. Please check username and password', 'danger') return render_template("login.html", title='Login', form=form)