def users_edit(user_id): user = User.query.get_or_404(user_id) form = UserEditForm(request.form) form.current_username.data = user.username form_pw = PasswordEditForm(obj=user) if not form.validate(): return render_template("auth/edit.html", form=form, form_pw=form_pw, user=user, updated="none") user.username = form.username.data user.name = form.name.data user.user_role = form.user_role.data db.session().add(user) db.session().commit() return render_template("auth/edit.html", form=form, form_pw=form_pw, user=user, updated="user")
def auth_registerOrUpdate(): if ('create' in request.form): form = RegisterForm(request.form) if not form.validate(): return render_template("auth/new.html", form=form) username = form.username.data password = form.password.data user = User(username, password, False) db.session().add(user) db.session().commit() login_user(user) elif ('edit' in request.form): form = UserEditForm(request.form) if not form.validate(): return render_template("auth/edit.html", form=form) oldUsername = form.oldUsername.data user = User.query.filter_by(username=oldUsername).first() user.username = form.username.data user.password = form.password.data db.session().commit() return redirect(url_for("games_index"))
def users_edit_form(user_id): user = User.query.get_or_404(user_id) form = UserEditForm(obj=user) form_pw = PasswordEditForm(obj=user) return render_template("auth/edit.html", form=form, form_pw=form_pw, user=user, updated="none")
def auth_edit(user_id): user = User.query.get(user_id) form = UserEditForm() form.oldUsername.data = user.username form.username.data = user.username form.password.data = user.password form.passwordSec.data = user.password return render_template("auth/edit.html", form=form, user=user)
def user(user_id): u = User.query.filter_by(id=user_id).first() if request.method == "GET": return render_template("auth/view.html", form=UserEditForm(obj=u)) form = UserEditForm(request.form) u = User.query.filter_by(id=form.id.data).first() if not form.validate(): return render_template("auth/view.html", form=form) u.salary = form.salary.data u.role = form.role.data db.session().commit() return redirect(url_for("users_index"))
def update_user(user_id): form = UserEditForm(request.form) if not form.validate(): return render_template("auth/viewuser.html", form=form, user=User.query.get(user_id)) user = User.query.get(user_id) name = request.form.get('name') username = request.form.get('username') password = request.form.get('password') if name is not '': user.name = name if username is not '': user.username = username if password is not '': user.password = password db.session().add(user) db.session().commit() return redirect(url_for("user_view", user_id=user_id))
def own_settings_pw(): user = current_user form = UserEditForm(obj=user) form_pw = PasswordEditForm(request.form) if not form_pw.validate(): return render_template("auth/ownsettings.html", form=form, form_pw=form_pw, updated="none") pw_hash = bcrypt.generate_password_hash( form_pw.password.data).decode('utf-8') user.password = pw_hash db.session().add(user) db.session().commit() return render_template("auth/ownsettings.html", form=form, form_pw=form_pw, updated="pw")
def users_edit_pw(user_id): user = User.query.get_or_404(user_id) form = UserEditForm(obj=user) form_pw = PasswordEditForm(request.form) if not form_pw.validate(): return render_template("auth/edit.html", form=form, form_pw=form_pw, user=user, updated="none") pw_hash = bcrypt.generate_password_hash( form_pw.password.data).decode('utf-8') user.password = pw_hash db.session().add(user) db.session().commit() return render_template("auth/edit.html", form=form, form_pw=form_pw, user=user, updated="pw")
def user_view(user_id): return render_template("auth/viewuser.html", user=User.query.get(user_id), form=UserEditForm())