Phase 7: the client link
Staff make a link for a person (or "+ New client": a record with only the name they know, and its link); the client fills in their own record from their phone without a login, and presses Send. - Links (src/links.rs, migrations/0006): the table keeps the SHA-256 of the token only, as sessions do; the link is shown once, to copy, to email (mailto with the person's address) or as a QR code (qrcode crate, inline SVG). It is open 14 days, until Send, or until staff close it; a new link closes the earlier one. States open, opened, sent, closed, expired. - The client's pages at /c/<token> (src/web/client.rs, client_*.html in a frame of their own, phone first): About you, Passport (the photo reader; a zone fills in the personal details still empty), Address in Thailand, Contact, Documents, Send. Each part is saved on its own, straight into the record. Forms carry the link's own token plus the same-site check. A passport with the same number is changed; an address unlike the current one is added beside it, so the current one and its TM.30 receipt stay; a second save changes what the link added. Uploads (passport page, photo, visa, arrival stamp, TDAC, work permit, other) go through the same checks and encrypted store as staff uploads, tied to the person's newest record of their kind. - Audit: the client's views and changes carry the actor `link <id>`; actions send and close and entity link are new. The person's page shows the newest links, when they were opened and sent, and each record the client changed, with the fields, to check. - Demo data: Erika sent her link an hour ago (phone and email changed), Jane opened hers. - documents::read_upload returns why it refused, so the client's pages answer in their own words. Checks: fmt, clippy; 101 unit and 54 integration tests (tests/client.rs: the link shown once and kept as a hash, a new client, the whole client flow with the login on, forged, closed, expired and made-up links); layout check light/dark desk/phone on the client pages, the person page and the new client form: no problems; the camera reader on the client's passport page with a fake camera filled the form and Send closed the link.
This commit is contained in:
1 parent
a6ebdfc89c
commit
43ed75d81b
32 files changed
+2706
-40
No files matched your search
@@ -0,0 +1,23 @@
|
||||
{% extends "client_base.html" %}
|
||||
{% block main %}
|
||||
<h1 class="chead">{% if first_name %}Hello {{ first_name }}{% else %}Hello{% endif %}</h1>
|
||||
<p class="lead2">B4L looks after your visa and your stay in Thailand. Fill in the parts below. Each part is saved on its own, so you can stop and come back to this link. When everything is in, press Send.</p>
|
||||
{% if saved %}<div class="notice ok" role="status">Saved: {{ saved }}.</div>{% endif %}
|
||||
<ol class="parts">
|
||||
{% for p in parts %}
|
||||
<li>
|
||||
<a class="part{% if p.done %} done{% endif %}" href="{{ base }}/{{ p.slug }}" id="part-{{ p.slug }}">
|
||||
<span class="pmark" aria-hidden="true">{% if p.done %}✓{% else %}{{ loop.index }}{% endif %}</span>
|
||||
<span class="pbody"><b>{{ p.title }}</b><span class="muted small">{{ p.what }}</span></span>
|
||||
<span class="chip {% if p.done %}ok{% else %}warn{% endif %}">{{ p.status }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
<form method="post" action="{{ base }}/send" class="card sendcard" id="send"{% if missing %} data-confirm="Still to do: {{ missing|join(", ") }}. Send anyway? The link closes once it is sent."{% else %} data-confirm="Send your details to B4L? The link closes once it is sent."{% endif %}>
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<h2>Send</h2>
|
||||
<p class="muted">{% if missing %}Still to do: {{ missing|join(", ") }}. You can send now and give the rest to B4L later.{% else %}Everything is in. Send it, and B4L checks it.{% endif %} After Send the link closes.</p>
|
||||
<button type="submit" class="btn pri" id="send-btn">Send to B4L</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,27 @@
|
||||
{% extends "client_base.html" %}
|
||||
{% import "_fields.html" as fm %}
|
||||
{% block main %}
|
||||
<div class="crumbs"><a href="{{ base }}">Your details</a></div>
|
||||
<h1 class="chead">About you</h1>
|
||||
<form method="post" action="{{ base }}/about" class="form" id="about-form">
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<section class="card">
|
||||
<p class="hint lead">Write your names exactly as the passport prints them.</p>
|
||||
<div class="grid">
|
||||
{{ fm.text("surname", "Surname", f.surname, err=errors.surname, req=true, auto="family-name") }}
|
||||
{{ fm.text("first_name", "First name", f.first_name, err=errors.first_name, req=true, auto="given-name") }}
|
||||
{{ fm.text("middle_name", "Middle names", f.middle_name, err=errors.middle_name, auto="additional-name") }}
|
||||
{{ fm.select("title", "Title", f.title, titles, err=errors.title, blank="Choose") }}
|
||||
{{ fm.select("sex", "Sex", f.sex, sexes, err=errors.sex, blank="Choose") }}
|
||||
{{ fm.text("date_of_birth", "Date of birth", f.date_of_birth, err=errors.date_of_birth, type="date", auto="bday") }}
|
||||
{{ fm.text("place_of_birth", "Place of birth", f.place_of_birth, err=errors.place_of_birth, hint="As in the passport.") }}
|
||||
{{ fm.select("nationality", "Nationality", f.nationality, countries, err=errors.nationality, blank="Choose a country") }}
|
||||
{{ fm.text("occupation", "Occupation", f.occupation, err=errors.occupation, cls="wide") }}
|
||||
</div>
|
||||
</section>
|
||||
<div class="formactions">
|
||||
<button type="submit" class="btn pri" id="save">Save</button>
|
||||
<a class="btn ghost" href="{{ base }}">Back</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,37 @@
|
||||
{% extends "client_base.html" %}
|
||||
{% import "_fields.html" as fm %}
|
||||
{% block main %}
|
||||
<div class="crumbs"><a href="{{ base }}">Your details</a></div>
|
||||
<h1 class="chead">Address in Thailand</h1>
|
||||
<form method="post" action="{{ base }}/address" class="form" id="address-form">
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<section class="card">
|
||||
<p class="hint lead">Where you live now, in the order Thai forms use. Leave out what your address does not have.</p>
|
||||
<div class="grid">
|
||||
{{ fm.text("house_no", "House number", af.house_no, err=errors.house_no, ph="99/9") }}
|
||||
{{ fm.text("moo", "Moo (village number)", af.moo, err=errors.moo) }}
|
||||
{{ fm.text("building", "Village, building or condominium", af.building, err=errors.building, hint="With the room number, if any.", cls="wide") }}
|
||||
{{ fm.text("soi", "Soi", af.soi, err=errors.soi) }}
|
||||
{{ fm.text("road", "Road", af.road, err=errors.road) }}
|
||||
{{ fm.text("subdistrict", "Subdistrict (tambon)", af.subdistrict, err=errors.subdistrict) }}
|
||||
{{ fm.text("district", "District (amphoe)", af.district, err=errors.district, req=true) }}
|
||||
{{ fm.text("province", "Province", af.province, err=errors.province, req=true, list="provinces") }}
|
||||
{{ fm.text("postal_code", "Postal code", af.postal_code, err=errors.postal_code, auto="postal-code") }}
|
||||
{{ fm.text("moved_in_on", "Moved in on", af.moved_in_on, err=errors.moved_in_on, type="date") }}
|
||||
</div>
|
||||
</section>
|
||||
<section class="card">
|
||||
<header><h2>House owner or landlord</h2></header>
|
||||
<p class="hint lead">They report your address to Immigration (form TM.30) after you move in and after every trip abroad.</p>
|
||||
<div class="grid">
|
||||
{{ fm.text("house_master", "Name", af.house_master, err=errors.house_master) }}
|
||||
{{ fm.text("house_master_phone", "Phone", af.house_master_phone, err=errors.house_master_phone, type="tel") }}
|
||||
</div>
|
||||
</section>
|
||||
<div class="formactions">
|
||||
<button type="submit" class="btn pri" id="save">Save</button>
|
||||
<a class="btn ghost" href="{{ base }}">Back</a>
|
||||
</div>
|
||||
</form>
|
||||
<datalist id="provinces">{% for pv in provinces %}<option value="{{ pv }}"></option>{% endfor %}</datalist>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,29 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<title>{{ title }} · B4L</title>
|
||||
<script src="/static/theme-init.js?v={{ v }}"></script>
|
||||
<link rel="icon" href="/static/favicon.svg?v={{ v }}" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="/static/app.css?v={{ v }}">
|
||||
<script src="/static/app.js?v={{ v }}" defer></script>
|
||||
</head>
|
||||
<body class="client">
|
||||
{#- The client's own frame: no sections, no sign-in, nothing of the
|
||||
staff's app. Every page of the link links back to its start. #}
|
||||
<header class="top">
|
||||
{% if base %}<a class="brand" href="{{ base }}" aria-label="Your details, the start">{% else %}<span class="brand">{% endif %}
|
||||
{% include "_mark.html" %}
|
||||
<span class="nm">Visa</span><span class="sub">B4L</span>
|
||||
{% if base %}</a>{% else %}</span>{% endif %}
|
||||
<button type="button" class="ib" id="themeBtn" aria-label="Switch between light and dark" title="Switch between light and dark">◐</button>
|
||||
</header>
|
||||
<main class="cmain" id="main">
|
||||
{% block main %}{% endblock %}
|
||||
{% if until %}<footer class="ft">This link works until {{ until }}. What you save here goes to B4L, who look after your visa and stay in Thailand; nobody else sees it.</footer>{% endif %}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
{% extends "client_base.html" %}
|
||||
{% block main %}
|
||||
<div class="card">
|
||||
<h1>{{ title }}</h1>
|
||||
<p>{{ text }}</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,20 @@
|
||||
{% extends "client_base.html" %}
|
||||
{% import "_fields.html" as fm %}
|
||||
{% block main %}
|
||||
<div class="crumbs"><a href="{{ base }}">Your details</a></div>
|
||||
<h1 class="chead">Contact</h1>
|
||||
<form method="post" action="{{ base }}/contact" class="form" id="contact-form">
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<section class="card">
|
||||
<p class="hint lead">B4L uses them to reach you about your visa and your deadlines.</p>
|
||||
<div class="grid">
|
||||
{{ fm.text("phone", "Phone", f.phone, err=errors.phone, type="tel", auto="tel", hint="With the country code if it is not a Thai number.") }}
|
||||
{{ fm.text("email", "Email", f.email, err=errors.email, type="email", auto="email") }}
|
||||
</div>
|
||||
</section>
|
||||
<div class="formactions">
|
||||
<button type="submit" class="btn pri" id="save">Save</button>
|
||||
<a class="btn ghost" href="{{ base }}">Back</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,38 @@
|
||||
{% extends "client_base.html" %}
|
||||
{% import "_fields.html" as fm %}
|
||||
{% block main %}
|
||||
<div class="crumbs"><a href="{{ base }}">Your details</a></div>
|
||||
<h1 class="chead">Documents</h1>
|
||||
<p class="lead2">Scans or photos of your papers: the passport's photo page, a passport photo (4 x 6 cm), your visa, the arrival stamp, the TDAC, the work permit. Upload one kind at a time.</p>
|
||||
{% if files_on %}
|
||||
<form method="post" action="{{ base }}/documents" enctype="multipart/form-data" class="upload card" id="upload">
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
{%- if errors %}
|
||||
<div class="notice warn">Nothing was uploaded. Correct what is marked and choose the files again.</div>
|
||||
{%- endif %}
|
||||
{{ fm.select("kind", "What the files are", v.kind, kinds, err=errors.kind, blank="Choose", req=true) }}
|
||||
<div class="drop{% if errors.file %} has-err{% endif %}" data-max="{{ file_limit }}">
|
||||
<input type="file" id="f-file" name="file" multiple required accept="application/pdf,image/jpeg,image/png,image/webp" aria-describedby="h-file{% if errors.file %} e-file{% endif %}">
|
||||
<span class="drop-icon" aria-hidden="true">+</span>
|
||||
<label for="f-file"><b>Choose files</b> or take a photo</label>
|
||||
<span class="drop-names" data-drop-names></span>
|
||||
<span class="hint" id="h-file">PDF, JPEG, PNG or WebP, up to {{ file_limit_mb }} MB each, {{ max_files }} at once</span>
|
||||
</div>
|
||||
{%- if errors.file %}
|
||||
<p class="err" id="e-file">{{ errors.file }}</p>
|
||||
{%- endif %}
|
||||
{{ fm.text("note", "Note", v.note, err=errors.note, ph="page 2") }}
|
||||
<div class="formactions"><button type="submit" class="btn pri" id="upload-btn">Upload</button><a class="btn ghost" href="{{ base }}">Back</a></div>
|
||||
</form>
|
||||
{% else %}
|
||||
<div class="notice warn">Uploads are switched off on this server. Give your papers to B4L instead.</div>
|
||||
{% endif %}
|
||||
<section class="card" id="uploaded">
|
||||
<header><h2>Uploaded through this link</h2></header>
|
||||
{% for d in uploaded %}
|
||||
<div class="item"><div class="row"><b>{{ d.label }}</b><span class="muted small">{{ d.at }}</span></div><div class="muted small fname">{{ d.file_name }}, {{ d.size }}</div></div>
|
||||
{% else %}
|
||||
<p class="empty-inline">Nothing yet.</p>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,34 @@
|
||||
{% extends "client_base.html" %}
|
||||
{% import "_fields.html" as fm %}
|
||||
{% block main %}
|
||||
<div class="crumbs"><a href="{{ base }}">Your details</a></div>
|
||||
<h1 class="chead">Passport</h1>
|
||||
<form method="post" action="{{ base }}/passport" class="form" id="passport-form">
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<button type="submit" name="action" value="save" class="default-submit" tabindex="-1" aria-hidden="true">Save</button>
|
||||
<section class="card" id="mrz-card">
|
||||
<header><h2>Read the passport</h2></header>
|
||||
<p class="hint lead">Take a photo of the passport's photo page: the two lines of letters and <<< at its bottom fill in the form. The photo stays on your phone; only the two lines are sent. You can also type the lines and press Read.</p>
|
||||
{{ fm.area("mrz", "The two lines at the bottom of the photo page", pf.mrz, err=errors.mrz, rows=2, cls="mrz") }}
|
||||
<div class="formactions">
|
||||
{% include "_mrz_photo.html" %}
|
||||
<button type="submit" name="action" value="read-mrz" class="btn" id="read-mrz" formnovalidate>Read</button>
|
||||
{% if mrz_note %}<p class="okline" role="status">{{ mrz_note }}</p>{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
<section class="card">
|
||||
<header><h2>Passport</h2></header>
|
||||
<div class="grid">
|
||||
{{ fm.text("number", "Passport number", pf.number, err=errors.number, req=true) }}
|
||||
{{ fm.select("issuing_country", "Issued by", pf.issuing_country, countries, err=errors.issuing_country, blank="Choose a country") }}
|
||||
{{ fm.text("issued_on", "Date of issue", pf.issued_on, err=errors.issued_on, type="date") }}
|
||||
{{ fm.text("expires_on", "Date of expiry", pf.expires_on, err=errors.expires_on, type="date", req=true) }}
|
||||
{{ fm.text("issued_at", "Authority or place of issue", pf.issued_at, err=errors.issued_at, hint="As printed in the passport.", cls="wide") }}
|
||||
</div>
|
||||
</section>
|
||||
<div class="formactions">
|
||||
<button type="submit" name="action" value="save" class="btn pri" id="save">Save</button>
|
||||
<a class="btn ghost" href="{{ base }}">Back</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,16 @@
|
||||
{% extends "base.html" %}
|
||||
{% block main %}
|
||||
{% include "_person_head.html" %}
|
||||
<section class="card linkcard" id="link-made">
|
||||
<header><h2>The client's link</h2></header>
|
||||
<p>Give this link to {{ p.name }}: by email or chat, or let them scan the code with their phone. It works until {{ until }}, or until they press Send.</p>
|
||||
<div class="linkrow">
|
||||
<input type="text" readonly value="{{ url }}" id="link-url" aria-label="The link" data-select-all>
|
||||
<button type="button" class="btn" data-copy="#link-url">Copy</button>
|
||||
{% if mail %}<a class="btn" href="{{ mail }}">Email it</a>{% endif %}
|
||||
</div>
|
||||
{% if qr %}<div class="qr" aria-label="The link as a QR code">{{ qr|safe }}</div>{% endif %}
|
||||
<p class="notice warn">The link is shown only now: the app keeps only a fingerprint of it. Copy it before you leave this page; otherwise make a new one, which closes this one.</p>
|
||||
<div class="formactions"><a class="btn pri" href="/people/{{ p.id }}#client-link">Done</a></div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,21 @@
|
||||
{% extends "base.html" %}
|
||||
{% import "_fields.html" as fm %}
|
||||
{% block main %}
|
||||
<div class="crumbs"><a href="/people">People</a></div>
|
||||
<div class="pagehead"><h1>New client</h1></div>
|
||||
<form method="post" action="/people/new-client" class="form" id="new-client-form">
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<section class="card">
|
||||
<p class="hint lead">A new record with the name you know, and a link for the client: they fill in the rest themselves, with the passport from a photo. The link works for 14 days, or until they press Send.</p>
|
||||
<div class="grid">
|
||||
{{ fm.text("surname", "Surname", f.surname, err=errors.surname) }}
|
||||
{{ fm.text("first_name", "First name", f.first_name, err=errors.first_name) }}
|
||||
{{ fm.text("email", "Email", f.email, err=errors.email, type="email", hint="Optional: the next page then offers an email with the link.") }}
|
||||
</div>
|
||||
</section>
|
||||
<div class="formactions">
|
||||
<button type="submit" class="btn pri" id="save">Make the record and its link</button>
|
||||
<a class="btn ghost" href="/people">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -2,7 +2,7 @@
|
||||
{% block main %}
|
||||
<div class="pagehead">
|
||||
<h1>{{ heading }}</h1>
|
||||
<div class="actions"><a class="btn pri" href="/people/new" id="new-person">+ New person</a></div>
|
||||
<div class="actions"><a class="btn" href="/people/new-client" id="new-client">+ New client</a><a class="btn pri" href="/people/new" id="new-person">+ New person</a></div>
|
||||
</div>
|
||||
{% if people or n_archived or company %}
|
||||
<form method="get" action="/people" class="toolbar" id="people-filter">
|
||||
|
||||
@@ -63,6 +63,30 @@
|
||||
{% endfor %}
|
||||
</section>
|
||||
|
||||
<section class="card" id="client-link">
|
||||
<header><h2>Client link</h2>
|
||||
<form method="post" action="/people/{{ p.id }}/links" class="inline-form"{% if client_links and client_links[0].usable %} data-confirm="Make a new link? The open one stops working."{% endif %}><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="btn sm" id="make-link">{% if client_links %}New link{% else %}Make a link{% endif %}</button></form>
|
||||
</header>
|
||||
{% for l in client_links %}
|
||||
<div class="item{% if not loop.first %} old{% endif %}">
|
||||
<div class="row">
|
||||
<span class="chip {{ l.level }}">{{ l.state }}</span>
|
||||
<span class="muted small">made {{ l.made }} by {{ l.by }}{% if l.usable %}, works until {{ l.until }}{% endif %}</span>
|
||||
</div>
|
||||
<dl class="kv">
|
||||
{% if l.opened %}<dt>Opened</dt><dd>{{ l.opened }}</dd>{% endif %}
|
||||
{% if l.sent %}<dt>Sent</dt><dd>{{ l.sent }}</dd>{% endif %}
|
||||
{% if l.closed %}<dt>Closed</dt><dd>{{ l.closed }}</dd>{% endif %}
|
||||
{% if l.changes %}<dt>Changed</dt><dd><ul class="changes">{% for c in l.changes %}<li><a href="{{ c.href }}">{{ c.label }}</a>{% if c.fields %} <span class="muted">({{ c.fields }})</span>{% endif %}</li>{% endfor %}</ul></dd>{% endif %}
|
||||
</dl>
|
||||
{% if l.changes %}<p class="hint">The client's entries went straight into the record: check them against the papers.</p>{% endif %}
|
||||
{% if l.usable %}<div class="rowactions"><form method="post" action="/people/{{ p.id }}/links/{{ l.id }}/close" class="inline-form" data-confirm="Close this link? The client can no longer use it."><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="linkbtn">Close the link</button></form></div>{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="empty-inline">A link lets the client fill in their own details, passport, address and scans from their phone, without a login. It works for 14 days, or until they press Send.</p>
|
||||
{% endfor %}
|
||||
</section>
|
||||
|
||||
<section class="card" id="recent">
|
||||
<header><h2>Recent activity</h2><a class="btn sm ghost" href="/activity?person={{ p.id }}">All of it</a></header>
|
||||
<ul class="log">
|
||||
|
||||
Reference in new issue
Block a user