ident
All repositories: gitoria
2.3 KB
// components/codestep.hl — THE CODE STEP of the sign-in (ident#40.2): the one-time-code form, placed by components/home.hl (the code page)// and components/embed.hl (the selector's frame). The host passes in WHO the code was sent to (sentTo) and the sentence's ending (tail);// this component owns the code field, the browser's time zone and the check against the server (face verifyCode, lib/login.hl// signInWithCode). What follows is the host's: it gets the answer through $parent.codeVerified(r) or $parent.codeFailed(text), and// "Other address" is $parent.back(). Markup, ids and look are those both pages had before (the CSS is components/styles.hl).import { signInWithCode } from '../lib/login.hl'sentTo = ''tail = '.'code = ''View {p { id = "sentto" class = "lead" "We sent a six-digit code to " strong { sentTo } tail }form { id = "codeform"on submit(e) {e.preventDefault()emit verify(e)}label { "One-time code"input { id = "code" name = "code" autocomplete = "one-time-code" inputmode = "numeric" pattern = "[0-9]{6}" maxlength = "6" required = "required" value = code on input(e) { emit setCode(e.target.value) } }}formButtons {button { id = "verify" type = "submit" "Sign in" }button { id = "back" type = "button" class = "quiet" "Other address" on click(e) { $parent.back() } }}}}on setCode(v) { code = v }// the browser's own time zone (IANA name) goes with the first login (`Intl` is a browser global of client code, hybriel#18)browserZone = () => { return Intl.DateTimeFormat().resolvedOptions().timeZone }on verify(e) {$parent.codeFailed('')r = emit server verifyCode(sentTo, code, browserZone())if (r == null) {$parent.codeFailed('the server did not answer — try again')return null}if (r.error != null) {$parent.codeFailed(r.error)return null}$parent.codeVerified(r)}// the right code signs the session in; the first one for an address creates the account, its default identity and stores the// browser's time zoneon server verifyCode(email, code, timeZone, session) {if (session == null) { return { error = 'no session — reload the page' } }if (email == null || hlTypeName(email) != 'String' || code == null || hlTypeName(code) != 'String') { return { error = 'email and code must be strings' } }return signInWithCode(&session, email, code, timeZone)}
Branches
Latest commits
- 6fad3bd2Merge branch 'f3-codestep' into mainIdent
- 51e387f2|||PR ident#40 the code step is one component (components/codestep.hl) placed by home.hl and embed.hl; its verify face, setCode, browserZone and verify call exist once (#40.2)mre
- c28bddeeMerge branch 'f2-shell' into mainIdent
- c3a40ff6|||PR ident#40 one shell for the app and /start (account part off on /start, #40.1); startshell.hl removed; unused signOut faces gone (#40.4)mre
- 060f3870ident#40.4: use the shell sign-out faces in regression gatesmre
- 9b94aa6aMerge branch 'f1b-cleanup' into mainIdent
- edcfce3f|||PR ident#41 ident#43 ident#44 login error page as a component (same status codes and text, pixel-identical), declarations and route wiring cleaned upmre
- 3ac85995ident#43 ident#44: plain declarations for never-reassigned lets, one envString helper, named route functions and audience rule out of project.hlmre
- c7eef14aMerge branch 'nv1-navigate' into mainIdent
- 644f9775|||PR ident#36 navigate() instead of window.location in the shell, start shell and homemre
- 4ca2f921deploy.sh: tar --hard-dereference so backups hold no hard linksmre
- 23971fb7ident#49: media queries in the language's @media formmre
- 73f4f97dident: re-vendor to hybriel day38b (mpackdb store-open fix)mre
- aa056c03ident: a startup error prints its message before exit 1 (hybriel#247)mre
- ee37a861ident#G48: gitoria's registration gets the wildcard origin of its repo addresses at load (gate tests/gitoria-origin.mjs)mre
- dc6d486fident#27: the docs gate expects the new Access entry in the main menumre
- d277633cident#27: README: identity access and the introspect endpointmre
- e999b0d3ident#27: the Access tab — one key per identity for all its apps: give access in three steps, the overview matrix, a cell's sheet (since, last use, level, rotate, revoke), the app's check POST /api/introspect, agent identities hidden from the login picker, an inbox icon in the header's icon style (gate: tests/access.mjs)mre
- 436206fcident#47: deploy.sh runs the sign-in gate on the deploy's own port slot, like the sessionwrites and docs gates (the default 8700 can be taken by another process)mre
- a4887ea3ident#47: the selector's sign-in frame no longer has a Continue button; the identity row itself is the link (gate tests/signin.mjs fails on the old code)mre