gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit9ced53c39ced53c3|||PR ident#33 ident#35 every component's styles live in its own Style block; styles.hl keeps the page-wide rest; the account bar is phone first (min-width: 60rem block); the avatar preview is hidden with the hidden attribute (ident#34 in part)mre9ced53c3/components/codestep.hl

2.4 KB

  1. // 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)
  2. // 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);
  3. // this component owns the code field, the browser's time zone and the check against the server (face verifyCode, lib/login.hl
  4. // signInWithCode). What follows is the host's: it gets the answer through $parent.codeVerified(r) or $parent.codeFailed(text), and
  5. // "Other address" is $parent.back(). Markup, ids and look are those both pages had before (the CSS is components/styles.hl).
  6. import { signInWithCode } from '../lib/login.hl'
  7. sentTo = ''
  8. tail = '.'
  9. code = ''
  10. Style {
  11. '#code' {
  12. fontSize = '1.4rem'
  13. letterSpacing = '.3em'
  14. fontVariantNumeric = 'tabular-nums'
  15. }
  16. }
  17. View {
  18. p { id = "sentto" class = "lead" "We sent a six-digit code to " strong { sentTo } tail }
  19. form { id = "codeform"
  20. on submit(e) {
  21. e.preventDefault()
  22. emit verify(e)
  23. }
  24. label { "One-time code"
  25. 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) } }
  26. }
  27. formButtons {
  28. button { id = "verify" type = "submit" "Sign in" }
  29. button { id = "back" type = "button" class = "quiet" "Other address" on click(e) { $parent.back() } }
  30. }
  31. }
  32. }
  33. on setCode(v) { code = v }
  34. // the browser's own time zone (IANA name) goes with the first login (`Intl` is a browser global of client code, hybriel#18)
  35. browserZone = () => { return Intl.DateTimeFormat().resolvedOptions().timeZone }
  36. on verify(e) {
  37. $parent.codeFailed('')
  38. r = emit server verifyCode(sentTo, code, browserZone())
  39. if (r == null) {
  40. $parent.codeFailed('the server did not answer — try again')
  41. return null
  42. }
  43. if (r.error != null) {
  44. $parent.codeFailed(r.error)
  45. return null
  46. }
  47. $parent.codeVerified(r)
  48. }
  49. // the right code signs the session in; the first one for an address creates the account, its default identity and stores the
  50. // browser's time zone
  51. on server verifyCode(email, code, timeZone, session) {
  52. if (session == null) { return { error = 'no session — reload the page' } }
  53. if (email == null || hlTypeName(email) != 'String' || code == null || hlTypeName(code) != 'String') { return { error = 'email and code must be strings' } }
  54. return signInWithCode(&session, email, code, timeZone)
  55. }

Branches

Latest commits

  • 9ced53c3|||PR ident#33 ident#35 every component's styles live in its own Style block; styles.hl keeps the page-wide rest; the account bar is phone first (min-width: 60rem block); the avatar preview is hidden with the hidden attribute (ident#34 in part)mre
  • f28333e4ident#33 ident#35: styles.hl keeps only the accent, the page column and the shared patterns; the account bar is written phone first (base rule + one min-width: 60rem block) instead of a max-width overridemre
  • 5b4541fcident#33: the selector sign-in frame's rules move into embed.hl's Stylemre
  • 00235f21ident#33: the per-app notification switches move into appsettings.hl's Stylemre
  • 2249945cident#33: the inbox and connection list rules move into inbox.hl's Stylemre
  • f2d9f79fident#33: the apps list and the secret box move into apps.hl's Stylemre
  • 8370b748ident#33: the app request box moves into home.hl's Stylemre
  • 40bf3b97ident#33: the 404 page's home link rule moves into notfound.hlmre
  • 40627a89ident#33: the time zone section's spacing moves into timezone.hlmre
  • d389db08ident#33: the identity page's rules and the Notif. chip move into identity.hl's Stylemre
  • 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