def set_password(): form = SetPasswordForm() if form.validate_on_submit(): current_user.password = form.password.data db.session.add(current_user) db.session.commit() flash("Password set successfully") return redirect(url_for("main.index")) return render_template("set_password.j2", form=form)
def set_password(): ''' View for setting the password on the first login. :return: set_password.html or redirect to views.index :rtype: HTML / Redirect ''' form = SetPasswordForm() if form.validate_on_submit(): password = form.password.data error = None if not password: error = "A password is required" if error is None: db = get_db() user_id = int(session['user_id']) db.execute( 'UPDATE user SET password = ? , first_login = ? WHERE id = ?', (generate_password_hash(password), 0, user_id)) db.commit() return redirect(url_for('views.index')) flash(error) return render_template('set_password.html', form=form)
def set_new_password(self): form = SetPasswordForm(request.form) self.user.set_password(form.password.data) self.user.save() flash("heslo nastaveno", "success") return redirect(url_for("UserView:show"))
def set_password(self): self.form = SetPasswordForm() return self.template("_set_password")