def set_role(): user = User.get(request.form['id']) role = Role.get(request.form['role']) enableDisable = strtobool(request.form['enable']) if user is None: abort(400, "An invalid user was given!") if role is None: abort(400, "An invalid role was given!") if enableDisable: user.add_role(role) else: user.remove_role(role) db.session.commit() return ("", http.HTTPStatus.NO_CONTENT)
def login(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = LoginForm() if form.validate_on_submit(): user = User.get(form.username.data) if user is not None and user.verify_password(form.password.data): login_user(FlaskUser(user), remember=form.remember_me.data) next_page = request.args.get('next') if not next_page or urlparse(next_page).netloc != '': next_page = url_for('main.home') return redirect(next_page) else: return render_template('login.html', title='Sign In', form=form, failed=True) return render_template('login.html', title='Sign In', form=form, failed=False)
def load_user(username): user = User.get(username) if user is None: return None return FlaskUser(user)
def get_current_user(key_only=False): user = users.get_current_user() return User.get(user.email(), key_only=key_only)
def delete(): user = User.get(request.form['id']) if user is not None: user.delete() db.session.commit() return ("", http.HTTPStatus.NO_CONTENT)
def get_waiter(self): return User.get(self.waiter)