gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit0dbff9600dbff960Merge branch 'f8-shared' into mainIdent0dbff960/components/codestep.hl

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

Branches

Latest commits

  • 0dbff960Merge branch 'f8-shared' into mainIdent
  • d69665f6|||PR ident#34 part 3: shared look classes (wide, avatar, chip/used, conn, choose, who, inboxlink) moved to statics or droppedmre
  • 3a64dc48ident#34: chipLook: radius as the same var() string (a bare token name in a static does not compile); selector gate selectormre
  • eb039073ident#34: tests: signin and migration find the choice without the classmre
  • 4b94a594ident#34: tests: fix selector of the identity choicemre
  • bebc88e4ident#34: main.hl drops the unstyled classes inboxlink and whomre
  • b4e7ad04ident#34: the identity choice link/button has no class (rule on #chooselist a)mre
  • 3c33d6eaident#34: the connection link in inbox has no class (rule on #conns a)mre
  • dc97ec0dident#34: the Notif. chip and the Used in link share chipLook (Style.pChip) instead of the classes chip/used/notifmre
  • 378bd432ident#34: the identity picture look is a static in styles.hl (Style.pAvatar); sizes stay with each listmre
  • 1cf79e7eident#34: the wide page column is a static in styles.hl (Style.pWide), not the class "wide"mre
  • ddc7d135Merge branch 'f7-hooks' into mainIdent
  • eee0b513|||PR ident#34 part: test-hook classes replaced by name/element/attribute selectors (tests adjusted), the shared lead/message/notice looks are statics in styles.hlmre
  • ccd6d0c4ident#34: browser gate: rowButton finds the row's button by namemre
  • 24dd414eident#34: the shared lead, message and notice looks are statics in components/styles.hl, imported by the components (lib/looks.hl gone)mre
  • 03ed26c7ident#34: access.hl: the remaining lead classes droppedmre
  • 1d066c42ident#34: access.hl drops its unstyled lead class (the shared lead rule would otherwise mute it)mre
  • 1e1dd7b4ident#34: the access page keeps its lead class string (the page has no ident-card, so its lead line was never muted; a shared rule would change the look)mre
  • 89ac6553ident#34: the lead, message and notice lines are named with Style.pLead / pMessage / pNotice (shared bodies in lib/looks.hl) instead of class stringsmre
  • e84be3deident#34: browser gate lists the Edit/Delete buttons by namemre