ident
All repositories: gitoria
2.4 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 = ''Style {'#code' {fontSize = '1.4rem'letterSpacing = '.3em'fontVariantNumeric = 'tabular-nums'}}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
- ddda0b5bident#33: the identity row's parts move into identitylist.hl's Stylemre
- 47e516afident#33 ident#34: the identity form's avatar rules move into identityform.hl; the preview and Remove button are hidden with the hidden attribute instead of built class strings (avatarPreviewClass, avatarRemoveClass gone)mre
- 5cb5cf0eident#33: the code field's look moves into codestep.hl's Stylemre
- f421cd60ident#33: the shell's own rules (user menu address, offline note, network probe) move into main.hl's Stylemre
- c512fb96Merge branch 'f4-homesplit' into mainIdent
- 07d1717c|||PR ident#40 home.hl is split into components, one per area: email step, identity form, identity list, app identity choice, time zone; each moves its faces with it, the email step is shared with embed.hl (#40.3, rest of #40.2)mre
- 59e8fcc1ident#40.3: the app's identity choice is one component (components/chooseidentity.hl); its face chooseIdentity moves with itmre
- e23efdfcident#40.3: the identity list is one component (components/identitylist.hl); its delete and face dropIdentity move with itmre
- e24b59a6ident#40.3: the time zone is one component (components/timezone.hl); its face changeTimeZone moves with itmre
- 8cbc5717ident#40.3: the email step is one component (components/emailstep.hl) placed by home.hl and embed.hlmre
- 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