(entry_id: int)
| 1906 | |
| 1907 | @app.route("/vault/view/<int:entry_id>") |
| 1908 | def vault_view(entry_id: int): |
| 1909 | gate = require_vault() |
| 1910 | if gate: |
| 1911 | return gate |
| 1912 | con = db_connect() |
| 1913 | row = con.execute("SELECT * FROM entries WHERE id=?", (entry_id,)).fetchone() |
| 1914 | con.close() |
| 1915 | if not row: |
| 1916 | flash("Entry not found.") |
| 1917 | return redirect(url_for("vault_home")) |
| 1918 | master = vault_master() |
| 1919 | try: |
| 1920 | username = vault_decrypt(master, row["username_enc"]) |
| 1921 | password = vault_decrypt(master, row["password_enc"]) |
| 1922 | notes = vault_decrypt(master, row["notes_enc"]) |
| 1923 | except Exception: |
| 1924 | flash("Could not decrypt entry. Unlock the vault again.") |
| 1925 | return redirect(url_for("vault_logout")) |
| 1926 | body = render_template_string( |
| 1927 | """ |
| 1928 | <section class="hero stack"> |
| 1929 | <div class="row" style="justify-content:space-between;align-items:flex-start;"><div><h1 style="margin:0 0 8px 0;">{{ r['title'] }}</h1><div class="muted small mono">{{ r['url'] }}</div></div><div class="row"><a class="btn primary" target="_blank" rel="noreferrer" href="{{ r['url'] }}">Open site</a><a class="btn" href="{{ url_for('vault_edit', entry_id=r['id']) }}">Edit</a></div></div> |
| 1930 | <div class="grid2"> |
| 1931 | <div class="card stack"> |
| 1932 | <div><label>Username</label><input id="u" value="{{ username }}" readonly></div> |
| 1933 | <div><label>Password</label><div class="row"><input id="p" type="password" value="{{ password }}" readonly style="flex:1;"><button class="btn" type="button" onclick="const p=document.getElementById('p');p.type=p.type==='password'?'text':'password'">Show/Hide</button></div></div> |
| 1934 | <div class="row"><button class="btn" type="button" onclick="navigator.clipboard.writeText(document.getElementById('u').value)">Copy username</button><button class="btn" type="button" onclick="navigator.clipboard.writeText(document.getElementById('p').value)">Copy password</button></div> |
| 1935 | </div> |
| 1936 | <div class="card stack"> |
| 1937 | <div><label>Notes</label><textarea id="n" readonly>{{ notes }}</textarea></div> |
| 1938 | <div class="row"><button class="btn" type="button" onclick="navigator.clipboard.writeText(document.getElementById('n').value)">Copy notes</button></div> |
| 1939 | <form method="post" action="{{ url_for('vault_delete', entry_id=r['id']) }}" onsubmit="return confirm('Delete this entry?');"><button class="btn danger" type="submit">Delete</button></form> |
| 1940 | </div> |
| 1941 | </div> |
| 1942 | </section> |
| 1943 | """, r=row, username=username, password=password, notes=notes |
| 1944 | ) |
| 1945 | return render_page("View entry", body) |
| 1946 | |
| 1947 | @app.route("/vault/edit/<int:entry_id>", methods=["GET", "POST"]) |
| 1948 | def vault_edit(entry_id: int): |
nothing calls this directly
no test coverage detected