ident
All repositories: gitoria
4.3 KB
// components/embed.hl — `/embed/signin?key=<api key>&return=<url>` (ident#31): THE SELECTOR'S SIGN-IN, shown inside the selector's// panel on an app's page (an iframe; lib/api.hl embedSignin checks key + return, parks the request like the login button and allows// framing only by the app's registered origins). Signed out of ident: email → code → the identity list, all in this frame, with one// 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// target="_top": the whole app page then goes to `<return>?ident_code=<code>` (lib/api.hl embedGo), the flow every app handles.// A new address (the account is created by the first right code) is sent on to ident in the same tab (`/signin/<rid>/welcome`)// to name its identity and pick it; ident then sends the browser back to the page it came from.parent './embedshell.hl'import { accountOfSession } from '../lib/accounts.hl'import EmailStep from './emailstep.hl'import CodeStep from './codestep.hl'import { identityRows } from '../lib/identities.hl'import { requestOf } from '../lib/apps.hl'session = nullrid = nullme = accountOfSession(&session)request = rid != null ? requestOf(rid) : nullappName = request != null ? request.app.name : ''identities = me != null ? identityRows(me.id) : []// the steps (a View's `if` takes a member): email → code → choose (or `fresh` for a new address)askEmail = me == nullaskCode = falsechoose = me != nullfresh = falsesentTo = ''message = ''rowsOf = (list) => {out = []for (row of list) { out.push({ label = row.label shortId = row.shortId href = '/embed/go?rid=' + rid + '&identity=' + row.id }) }return out}choices = rowsOf(identities)newHref = '/signin/' + rid + '/welcome'View {embedCard {if (askEmail) {fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }p { id = "embednote" class = "lead" "This signs you in to ident. We mail you a one-time code." }EmailStep {}}if (askCode) {fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }CodeStep { sentTo = sentTo tail = '.' }}if (choose) {fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }p { class = "lead" "You are signed in to ident. Choose the identity to log in to " strong { appName } " with." }ul { id = "chooselist"for (row of choices) {li { class = "choice"a { class = "choose" target = "_top" href = row.hrefidentityMain { identityLabel { row.label } identityShortId { class = "shortid" row.shortId } }}}}}}if (fresh) {fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }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." }a { id = "gonew" class = "button" target = "_top" href = newHref "Create my identity" }}p { id = "message" class = "message" message }}}// 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// fitMark whose CSS animation starts when the step appears (and repeats each second for a resize or a message): then the page's content// height goes to the parent window. No JavaScript of ours; selector.js accepts it from ident's origin only.on fit(e) {// the card's bottom edge, not the document's height (the document is as tall as the frame, so it could never shrink)card = document.querySelector('embed-card')if (card != null) { window.parent.postMessage({ identFrameHeight = Math.ceil(card.getBoundingClientRect().bottom + window.scrollY) }, '*') }}// the email step (components/emailstep.hl) asked for a code (the plain POST to /api/code): the frame goes on to the code stepemailSent = (String address) => {sentTo = addressaskEmail = falseaskCode = true}// the code step (components/codestep.hl) checked the code: the answer, or why notcodeFailed = (String text) => { message = text }codeVerified = (r) => {askCode = falseidentities = r.identitieschoices = rowsOf(r.identities)if (r.created) {fresh = true} else {choose = true}}back = () => {message = ''askCode = falseaskEmail = true}
Branches
Latest commits
- 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
- 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