gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitc512fb96c512fb96Merge branch 'f4-homesplit' into mainIdentc512fb96/components/embed.hl

4.3 KB

  1. // components/embed.hl — `/embed/signin?key=<api key>&return=<url>` (ident#31): THE SELECTOR'S SIGN-IN, shown inside the selector's
  2. // panel on an app's page (an iframe; lib/api.hl embedSignin checks key + return, parks the request like the login button and allows
  3. // framing only by the app's registered origins). Signed out of ident: email → code → the identity list, all in this frame, with one
  4. // note that this signs the user in to ident. Choosing an identity (the identity row itself, no extra Continue click), and the way on for a NEW address, are plain links with
  5. // target="_top": the whole app page then goes to `<return>?ident_code=<code>` (lib/api.hl embedGo), the flow every app handles.
  6. // A new address (the account is created by the first right code) is sent on to ident in the same tab (`/signin/<rid>/welcome`)
  7. // to name its identity and pick it; ident then sends the browser back to the page it came from.
  8. parent './embedshell.hl'
  9. import { accountOfSession } from '../lib/accounts.hl'
  10. import EmailStep from './emailstep.hl'
  11. import CodeStep from './codestep.hl'
  12. import { identityRows } from '../lib/identities.hl'
  13. import { requestOf } from '../lib/apps.hl'
  14. session = null
  15. rid = null
  16. me = accountOfSession(&session)
  17. request = rid != null ? requestOf(rid) : null
  18. appName = request != null ? request.app.name : ''
  19. identities = me != null ? identityRows(me.id) : []
  20. // the steps (a View's `if` takes a member): email → code → choose (or `fresh` for a new address)
  21. askEmail = me == null
  22. askCode = false
  23. choose = me != null
  24. fresh = false
  25. sentTo = ''
  26. message = ''
  27. rowsOf = (list) => {
  28. out = []
  29. for (row of list) { out.push({ label = row.label shortId = row.shortId href = '/embed/go?rid=' + rid + '&identity=' + row.id }) }
  30. return out
  31. }
  32. choices = rowsOf(identities)
  33. newHref = '/signin/' + rid + '/welcome'
  34. View {
  35. embedCard {
  36. if (askEmail) {
  37. fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }
  38. p { id = "embednote" class = "lead" "This signs you in to ident. We mail you a one-time code." }
  39. EmailStep {}
  40. }
  41. if (askCode) {
  42. fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }
  43. CodeStep { sentTo = sentTo tail = '.' }
  44. }
  45. if (choose) {
  46. fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }
  47. p { class = "lead" "You are signed in to ident. Choose the identity to log in to " strong { appName } " with." }
  48. ul { id = "chooselist"
  49. for (row of choices) {
  50. li { class = "choice"
  51. a { class = "choose" target = "_top" href = row.href
  52. identityMain { identityLabel { row.label } identityShortId { class = "shortid" row.shortId } }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. if (fresh) {
  59. fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }
  60. p { id = "freshnote" class = "lead" "This address is new to ident, so it has an account now. Create your identity on ident: it takes you there and brings you back to this page." }
  61. a { id = "gonew" class = "button" target = "_top" href = newHref "Create my identity" }
  62. }
  63. p { id = "message" class = "message" message }
  64. }
  65. }
  66. // THE FRAME'S HEIGHT: the selector (selector.js) cannot read this page's height across origins, so the page tells it. Every step has a
  67. // fitMark whose CSS animation starts when the step appears (and repeats each second for a resize or a message): then the page's content
  68. // height goes to the parent window. No JavaScript of ours; selector.js accepts it from ident's origin only.
  69. on fit(e) {
  70. // the card's bottom edge, not the document's height (the document is as tall as the frame, so it could never shrink)
  71. card = document.querySelector('embed-card')
  72. if (card != null) { window.parent.postMessage({ identFrameHeight = Math.ceil(card.getBoundingClientRect().bottom + window.scrollY) }, '*') }
  73. }
  74. // the email step (components/emailstep.hl) asked for a code (the plain POST to /api/code): the frame goes on to the code step
  75. emailSent = (String address) => {
  76. sentTo = address
  77. askEmail = false
  78. askCode = true
  79. }
  80. // the code step (components/codestep.hl) checked the code: the answer, or why not
  81. codeFailed = (String text) => { message = text }
  82. codeVerified = (r) => {
  83. askCode = false
  84. identities = r.identities
  85. choices = rowsOf(r.identities)
  86. if (r.created) {
  87. fresh = true
  88. } else {
  89. choose = true
  90. }
  91. }
  92. back = () => {
  93. message = ''
  94. askCode = false
  95. askEmail = true
  96. }

Branches

Latest commits

  • 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
  • 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