def device_view(device_id): device = current_user.get_device(device_id) if device is not None: device_owner = User.get(user_id=device.device_owner) return render_template("admin/admin_device.html", device=device, device_owner=device_owner) else: abort(403)
def participate(): form = LoginForm(request.form) error = None if request.method == 'POST' and form.validate(): user = User.get(email=form.email.data) if user is not None: if user.authenticate(form.password.data): if login_user(user, remember=True): return redirect(request.args.get("next") or url_for("user_views.devices_view")) else: error = "Email and password do not match!" else: error = "A user with this email does not exist!" return render_template("participate.html", form=form, error=error)
def participate(): form = LoginForm(request.form) error = None if request.method == 'POST' and form.validate(): user = User.get(email=form.email.data) if user is not None: if user.authenticate(form.password.data): if login_user(user, remember=True): return redirect( request.args.get("next") or url_for("user_views.devices_view")) else: error = "Email and password do not match!" else: error = "A user with this email does not exist!" return render_template("participate.html", form=form, error=error)
def forgot_password(): forgot_form = ForgotPasswordForm(request.form) error = None if request.method == 'POST': if forgot_form.validate() and recaptcha_check(request.form["g-recaptcha-response"]): user = User.get(email=forgot_form.email.data) if user is not None: if user.forgot_password(): link = url_for("common_views.change_password", user_id=user.user_id, secret=user.forgot_secret, _external=True) current_app.logger.info(link) mail = mail_handler.Mail(user.email, link) mail.send() return redirect(url_for("common_views.index")) else: error = "A user with this email does not exist!" else: error = "Please enter email address and prove you are not a robot!" return render_template("forgot.html", forgot_form=forgot_form, error=error)
def forgot_password(): forgot_form = ForgotPasswordForm(request.form) error = None if request.method == 'POST': if forgot_form.validate() and recaptcha_check( request.form["g-recaptcha-response"]): user = User.get(email=forgot_form.email.data) if user is not None: if user.forgot_password(): link = url_for("common_views.change_password", user_id=user.user_id, secret=user.forgot_secret, _external=True) current_app.logger.info(link) mail = mail_handler.Mail(user.email, link) mail.send() return redirect(url_for("common_views.index")) else: error = "A user with this email does not exist!" else: error = "Please enter email address and prove you are not a robot!" return render_template("forgot.html", forgot_form=forgot_form, error=error)
def load_user(user_id): return User.get(user_id)