Example #1
0
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)
Example #2
0
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)
Example #3
0
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)
Example #4
0
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)
Example #5
0
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)
Example #6
0
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)
Example #7
0
def load_user(user_id):
    return User.get(user_id)
Example #8
0
def load_user(user_id):
    return User.get(user_id)