tickets
All repositories: gitoria
4.5 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 '../connections.hl'import { siteName } from '../project.hl'import { userOfSession, writerOfSession, canWriteSession } from '../users.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')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" class = "hint"strong { 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" class = "hint" "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" class = "message" message }}}if (done) {p { id = "connected" class = "notice" "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 }let 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) {let 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) {let u = userOfSession(session)if (u == null) { return { error = 'log in first' } }return { projects = adminProjects(u) }}on server connectConfirm(nonce, projectId, title, session) {let 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' } }let 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
- mainmain branch
Latest commits
- e01c2b1dtickets#24: installable app (manifest, service worker, offline list), own icon; gate waits for the hello's pongmre
- 752fbb7fdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- 38bdd5e4deploy.sh: never send .git or .gitignore to Byrodinmre
- f12fa1bcState of 2026-09-27, before the move to gitoriamre