quinone / password-manager

Password management application developed as a group project for college.
0 stars 0 forks source link

Add Preference page #42

Closed Pitoche closed 9 hours ago

Pitoche commented 1 month ago

Add Preference pages and link fields to DB

quinone commented 1 month ago

What preferences do we want?

Custom time limit for auto log out

I would like to increase the time before logging out. Maybe adding a field for that? We can set the default to 5 minutes?

Toggle light/dark mode

Using bootstrap we should be easily able to add a toggle light and dark mode. By adding an if statement to base.html it should be as simple as swapping "dark" and "light" in the tag

<html lang="en" data-bs-theme="dark">
<html lang="en" data-bs-theme="light">
Pitoche commented 3 weeks ago

I added some fields back on the 4th JUNNE but now I am not getting anything

quinone commented 3 weeks ago

So the blueprint for /settings needed to be added to create_app().

Yeah, are you looking to use flask-login? Was that from you or @Rachie94 ?

Pitoche commented 3 weeks ago

Mine was just a page with 2 fields as I had little time. but right now I am getting an error

quinone commented 3 weeks ago

This wasn't you?


login_manager = LoginManager()
login_manager.init_app(app)

bp = Blueprint("settings", __name__, url_prefix="/setting", template_folder="templates")

@bp.route("/", methods=["GET", "POST"])
@login_required
def settings():
    if request.method == "POST":
        vault_timeout = request.form.get("vaultTimeout", default="00:05:00")
        theme_id = request.form.get("themeId", default="light")
        settings_html = request.form.get(
            "settingsHtml", default=""
        )  # Get HTML content from the form

        try:
            conn = get_db()
            cursor = conn.cursor()
            cursor.execute(
                "REPLACE INTO preferences (user_id, vault_timeout, theme_id, settings_html) VALUES (?, ?, ?, ?)",
                (
                    current_user.id,
                    vault_timeout,
                    theme_id,
                    settings_html,
                ),  # Use current_user.id to get user_id
            )
            conn.commit()
            cursor.close()
            conn.close()
            flash("Preferences saved successfully", "success")
        except Exception as e:
            flash(f"Failed to save preferences: {str(e)}", "danger")

        return redirect(url_for("settings.settings"))

    return render_template("settings.html")```
Pitoche commented 3 weeks ago

I think so..

quinone commented 3 weeks ago

Think its fixed now. Try git fetch on development branch. I've commented out flask-login. Its a great module but would require a large refactoring if we are going to use it fully.

Pitoche commented 3 weeks ago

I now have 2 "settings" links and both work Not sure where the "other" is coming from

quinone commented 3 weeks ago

I updated to use { URL_for('settings.settings')} and forgot to remove the old link. Ill remove in next push

12 Jun 2024 21:23:29 Angel De Luis @.***>:

I now have 2 "settings" links and both work Not sure where the "other" is coming from

— Reply to this email directly, view it on GitHub[https://github.com/quinone/password-manager/issues/42#issuecomment-2163834718], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AG7KV6HJ4YDVMRM27YGGC43ZHCU4DAVCNFSM6AAAAABI2GLM36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRTHAZTINZRHA]. You are receiving this because you commented. [Tracking image][https://github.com/notifications/beacon/AG7KV6GLYTKCT4QRWMY43GDZHCU4DA5CNFSM6AAAAABI2GLM36WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUA7F7V4.gif]