tickets
All repositories: gitoria
4.8 KB
// components/connect.hl — `/connect/:nonce` (ticket #21): another app (first: gitoria) asks to be connected to one// project. The person — logged in through ident, with a display name — picks a project they are ADMIN of, or makes a// new one, and confirms. Then the page links back to the app with a one-time code (connections.hl); the app's server// swaps the code for a key that reaches that one project. Everybody else sees the login hint; a used or expired// request says so. Everything is checked again by the store in the faces.parent './main.hl'import { requestOf, requestView, adminProjects, confirmRequest } from '../lib/connections.hl'import { siteName } from '../project.hl'import { userOfSession, writerOfSession, canWriteSession } from '../lib/users.hl'import { hintLook, messageLook, noticeLook } from '../lib/looks.hl'nonce = nullsession = nullpending = requestOf(nonce)valid = pending != nullgone = pending == nullinfo = pending != null ? requestView(pending) : { app = '' label = '' hasLabel = false host = '' }appName = info.appappLabel = info.labelhasLabel = info.hasLabelappHost = info.hostcanWrite = valid && canWriteSession(session)showForm = valid && canWriteSession(session)mustLogIn = valid && !canWriteSession(session)choices = adminProjects(userOfSession(session))choice = choices.length > 0 ? choices[0].id : ''makeNew = choices.length == 0newTitle = ''message = ''done = falsedoneUrl = ''doneProject = ''__title = siteName + ' | connect ' + (pending != null ? pending.app : 'an app')Style {pHint = hintLook + { }'#connectmessage' = messageLook + { }'#connected' = noticeLook + { }connectPage {display = 'grid'gap = '1rem'maxWidth = '38rem'form {display = 'grid'gap = '.8rem'}}}View {connectPage {if (gone) { p { id = "gone" class = "empty" "This connection request is used up or expired. Start again from the app." } }if (valid) {h1 { id = "connecttitle" "Connect " appName " to a project" }p { id = "connectwho" Style.pHintstrong { appName }if (hasLabel) { " (" appLabel ")" }" at "strong { appHost }" asks for a key to ONE of your projects. With it the app can open tickets, comment and change their state there — for the people who work in it, within their roles. You can disconnect it on the project's page at any time."}}if (mustLogIn) { p { id = "loginhint" Style.pHint "Log in with ident (top right) and choose a display name to connect." } }if (showForm) {form { id = "connectform"on submit(e) {e.preventDefault()emit confirm(e)}label { "Project"select { id = "connectproject" name = "project" value = choice on change(e) { emit setChoice(e.target.value) }for (c of choices) { option { value = c.id c.title } }option { value = "" "A new project" }}}if (makeNew) {label { "Title of the new project"input { id = "connecttitleinput" name = "title" required = "required" maxlength = "100" autocomplete = "off" value = newTitle on input(e) { emit setNewTitle(e.target.value) } }}}button { id = "connectconfirm" type = "submit" "Connect" }p { id = "connectmessage" message }}}if (done) {p { id = "connected" "Connected to " strong { doneProject } ". " }a { id = "connectcontinue" class = "button" href = doneUrl "Continue to " appName }}}}on setChoice(v) {choice = vmakeNew = v == ''}on setNewTitle(v) { newTitle = v }on confirm(e) {if (makeNew && newTitle.trim() == '') { return null }r = emit server connectConfirm(nonce, choice, newTitle)if (r == null || r.error != null) {message = r != null ? r.error : 'could not connect'return null}message = ''showForm = falsedoneUrl = r.urldoneProject = r.projectdone = true}on client signedIn(tag, info) {r = emit server connectChoices()if (r != null && r.projects != null) {choices = r.projectschoice = r.projects.length > 0 ? r.projects[0].id : ''makeNew = r.projects.length == 0}canWrite = valid && info.namedshowForm = valid && info.named && !donemustLogIn = valid && !info.named}on client signedOut(tag) {canWrite = falseshowForm = falsemustLogIn = validchoices = []}on server connectChoices(session) {u = userOfSession(session)if (u == null) { return { error = 'log in first' } }return { projects = adminProjects(u) }}on server connectConfirm(nonce, projectId, title, session) {w = writerOfSession(session)if (w.error != null) { return { error = w.error } }if (hlTypeName(nonce) != 'String' || hlTypeName(projectId) != 'String' || hlTypeName(title) != 'String') { return { error = 'nonce, project and title must be text' } }r = confirmRequest(nonce, w.user, projectId, title)if (r.error != null) { return { error = r.error } }return { url = r.url project = r.project slug = r.slug }}
Branches
Latest commits
- aa2d124eREADME: the #94 purge gatemre
- e843ff7cOne-time purge of miserit-anthar#94 (#94, identity rule): idempotent step in lib/migrate.hl, fixture gate tests/purge94.mjsmre
- 506a4efdmission 028: #94, identity rulemre
- 78c7f48eRefine mpackdb holdmre
- 3d7d89c8Record mpackdb hold until day38mre
- f1bf7195#51 done; my subscription idmre
- 9870b945status: #51 proof greenmre
- e92173c6log: #51 live push proofmre
- 72d87041log: Hermes push livemre
- 1d69bf7dTickets conductor: park until Hermes pushmre
- 80d8cfd1Tickets conductor: #51 livemre
- 61641dd9Complete subscriptions deployment evidencemre
- c980856cRecord successful subscriptions deployment and live checksmre
- 4b4710adMerge branch 's51-subscriptions'mre
- a731ef7eTickets conductor: S51 reviewed, deploy stepmre
- b487b05aRecord verified direct push protocol handoffmre
- 74e34cc3Verify encrypted push secrets and direct push retry semanticsmre
- a1ac5cd0Push subscription notices directly to signed HyperConductor chat endpointsmre
- d662ad27Remove superseded waker service for direct chat push protocolmre
- c0ac927aTickets conductor: S51 redo for push protocolmre