toolroll 0.9.107 → 0.9.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +4 -3
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +27 -25
- package/dist/browser-shell.js +1 -1
- package/dist/cli-help.js +5 -0
- package/dist/contracts/cli.js +2 -0
- package/dist/contracts/console-api.js +1 -1
- package/dist/folder-look.js +65 -4
- package/dist/guides.js +3 -1
- package/dist/lead-cli.js +2 -1
- package/dist/live-bus.js +14 -1
- package/dist/login-secrets.js +43 -0
- package/dist/operate.js +167 -18
- package/dist/project-admission.js +60 -29
- package/dist/project.js +73 -0
- package/dist/repos.js +37 -0
- package/dist/route-hooks.js +1 -0
- package/dist/sample-project.js +167 -9
- package/dist/scope.js +17 -2
- package/dist/serve.js +15 -3
- package/dist/server/live.js +5 -2
- package/dist/server/login-help.js +67 -0
- package/dist/server/pages.js +180 -26
- package/dist/server/people-tokens.js +36 -24
- package/dist/server/render-people.js +14 -2
- package/dist/server/render-projects.js +58 -10
- package/dist/server/route-table.js +2 -1
- package/dist/server/settings.js +3 -0
- package/dist/server/welcome.js +29 -18
- package/dist/settings-groups-ui.js +10 -1
- package/dist/store.js +33 -0
- package/dist/surface.js +4 -1
- package/dist/task-outcome-cli.js +99 -4
- package/dist/tui-source.js +11 -3
- package/dist/tui.js +39 -39
- package/dist/welcome-facts.js +12 -5
- package/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { lstatSync, realpathSync } from "node:fs";
|
|
2
|
+
import { homedir, userInfo } from "node:os";
|
|
3
|
+
import { dirname, sep } from "node:path";
|
|
4
|
+
import { savedLoginFile } from "../login-secrets.js";
|
|
5
|
+
import { localOwnerBinding } from "../store.js";
|
|
6
|
+
export function shownPath(path, home, user) {
|
|
7
|
+
const homes = new Set([home]);
|
|
8
|
+
try {
|
|
9
|
+
homes.add(realpathSync(home));
|
|
10
|
+
}
|
|
11
|
+
catch { }
|
|
12
|
+
for (const one of homes) {
|
|
13
|
+
if (one === "" || one === sep)
|
|
14
|
+
continue;
|
|
15
|
+
const rest = path === one ? "" : path.startsWith(one + sep) ? path.slice(one.length) : null;
|
|
16
|
+
if (rest === null)
|
|
17
|
+
continue;
|
|
18
|
+
if (user !== null && user !== "" && rest.split(/[\\/]/).includes(user))
|
|
19
|
+
return null;
|
|
20
|
+
return `~${rest}`;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const regularFile = (path) => {
|
|
25
|
+
try {
|
|
26
|
+
return lstatSync(path).isFile();
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function databaseFileOf(store) {
|
|
33
|
+
const row = store.handle.prepare("PRAGMA database_list").all().find(one => one["name"] === "main");
|
|
34
|
+
return typeof row?.["file"] === "string" ? row["file"] : "";
|
|
35
|
+
}
|
|
36
|
+
function anyPasswordSet(store) {
|
|
37
|
+
return store.handle.prepare("SELECT 1 AS one FROM approver WHERE revoked_at IS NULL AND password_set = 1 AND credential_hash NOT LIKE 'sso-only$%' LIMIT 1").get() !== undefined;
|
|
38
|
+
}
|
|
39
|
+
export function loginHelpOf(store, where) {
|
|
40
|
+
try {
|
|
41
|
+
if (store.isDemo())
|
|
42
|
+
return { kind: "none" };
|
|
43
|
+
if (localOwnerBinding(store) !== null)
|
|
44
|
+
return { kind: "local", passwordSet: where.here ? anyPasswordSet(store) : null };
|
|
45
|
+
if (!where.here)
|
|
46
|
+
return { kind: "password", savedAt: null };
|
|
47
|
+
const database = databaseFileOf(store);
|
|
48
|
+
if (database === "")
|
|
49
|
+
return { kind: "password", savedAt: null };
|
|
50
|
+
const saved = savedLoginFile(dirname(database));
|
|
51
|
+
if (!regularFile(saved))
|
|
52
|
+
return { kind: "password", savedAt: null };
|
|
53
|
+
let user = where.user === undefined ? null : where.user;
|
|
54
|
+
if (where.user === undefined) {
|
|
55
|
+
try {
|
|
56
|
+
user = userInfo().username;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
user = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return { kind: "password", savedAt: shownPath(saved, where.home ?? homedir(), user) };
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return { kind: "password", savedAt: null };
|
|
66
|
+
}
|
|
67
|
+
}
|
package/dist/server/pages.js
CHANGED
|
@@ -7,13 +7,12 @@ import { handlersOf } from './handler-registry.js';
|
|
|
7
7
|
import { html, joinHtml, postForm, reauth } from "../html.js";
|
|
8
8
|
import * as kit from "./kit.js";
|
|
9
9
|
import { createHmac, randomBytes } from "node:crypto";
|
|
10
|
-
import { realpathSync } from "node:fs";
|
|
11
10
|
import {} from "node:http";
|
|
12
11
|
import { homedir, hostname } from "node:os";
|
|
13
12
|
import { basename, dirname, join, resolve } from "node:path";
|
|
14
13
|
import { builderReadyFor, buildersFor, firstRunBuilderRepo } from "../dispatch.js";
|
|
15
14
|
import { withBuilderStep } from "../first-run.js";
|
|
16
|
-
import { listFolder, localOrigins } from "../folder-look.js";
|
|
15
|
+
import { folderFacts, listFolder, localOrigins } from "../folder-look.js";
|
|
17
16
|
import { Readable } from "node:stream";
|
|
18
17
|
import { pipeline } from "node:stream/promises";
|
|
19
18
|
import { setImmediate as yieldEventLoop } from "node:timers/promises";
|
|
@@ -39,8 +38,9 @@ import { prometheusMetrics } from "../metrics.js";
|
|
|
39
38
|
import { readMonitoring } from "../monitoring-settings.js";
|
|
40
39
|
import { targetOf } from "../monitoring.js";
|
|
41
40
|
import { cloneGithubRepo, isLargeRepo, listGithubRepos, parseGithubRepo, previewGithubRepo } from "../onboard.js";
|
|
42
|
-
import { admitProject, releaseProject } from "../project-admission.js";
|
|
43
|
-
import {
|
|
41
|
+
import { admitProject, proveProjectRoot, releaseProject } from "../project-admission.js";
|
|
42
|
+
import { typedPasswordNow } from "../scope.js";
|
|
43
|
+
import { authorizedProject, canonicalProject, expandHomePath, isGitRepo, comparisonPaths, comparisonsOf, folderRefusal, projectName, sameRepo } from "../project.js";
|
|
44
44
|
import { publishingOf } from '../pull-request-flow.js';
|
|
45
45
|
import { register as registerRunner } from "../runner.js";
|
|
46
46
|
import { healthWords } from "../server-telemetry.js";
|
|
@@ -61,7 +61,8 @@ import { codeMapReport } from "../code-map-report.js";
|
|
|
61
61
|
import { codeMapPage, codeMapReportBlock } from "./render-code-map.js";
|
|
62
62
|
import { FLAKY_WINDOW_DAYS, flakyList, flakyShow } from "../flaky.js";
|
|
63
63
|
import { flakyPage, flakyRowPage } from "./render-flaky.js";
|
|
64
|
-
import {
|
|
64
|
+
import { configBase, NAMES } from "../names.js";
|
|
65
|
+
import { browsePage, folderPickerPage, githubReposPage, pickRepoChosen, outsideAddPage, shortPathOf, projectHref, projectPage, projectsPage, unknownProject } from "./render-projects.js";
|
|
65
66
|
import { notFound as kitNotFound } from "./kit.js";
|
|
66
67
|
import {} from "./render-pages.js";
|
|
67
68
|
import {} from "../project-outcomes.js";
|
|
@@ -74,7 +75,7 @@ import { homeView } from "./home.js";
|
|
|
74
75
|
import { flowAsks, releaseAsks, setupAsks } from "./home-asks.js";
|
|
75
76
|
import { workIndexPage } from "../work-index.js";
|
|
76
77
|
export function createPagesHandlers(runtime) {
|
|
77
|
-
const { identities, clock, lastChecks, store, visible, consoleProjects, restricted, ceiling, options, projectFamilyPeek, sendScreen, chromeFor, unscopedMode, admissionList, taskRepoOf, taskViewData, runVisible, evidenceRoot, workAccess, identify, liveCeiling, sessions, deletedRepos, authenticateApprover, authenticateCredential, projectOf, lookupSession, firstRunStepsNow, chatEnablement, leadPrincipal, leadConversationRows } = runtime;
|
|
78
|
+
const { identities, clock, lastChecks, store, visible, consoleProjects, restricted, ceiling, options, projectFamilyPeek, sendScreen, chromeFor, unscopedMode, admissionList, taskRepoOf, taskViewData, runVisible, evidenceRoot, workAccess, identify, liveCeiling, sessions, deletedRepos, authenticateApprover, authenticateCredential, projectOf, lookupSession, firstRunStepsNow, chatEnablement, leadPrincipal, leadConversationRows, outsideAdmissions } = runtime;
|
|
78
79
|
async function projectsBrowse(ctx) {
|
|
79
80
|
const { url, who, response } = ctx;
|
|
80
81
|
if (who.via !== "cookie")
|
|
@@ -524,38 +525,84 @@ export function createPagesHandlers(runtime) {
|
|
|
524
525
|
if (who.via !== "cookie") {
|
|
525
526
|
return refuse(response, who, 403, "opening a project is a browser session's act");
|
|
526
527
|
}
|
|
527
|
-
const
|
|
528
|
+
const pathTyped = (body.get("path") ?? "").trim();
|
|
529
|
+
const at = body.get("via") === "path" ? "path" : "open";
|
|
530
|
+
const back = safeReturn(body.get("return"));
|
|
531
|
+
const say = (words, status) => void projectsScreen(response, who, words, status, back, at, at === "path" ? pathTyped : "");
|
|
532
|
+
const asked = pathTyped.length === 0 ? "" : expandHomePath(pathTyped, homedir());
|
|
533
|
+
if (asked === null)
|
|
534
|
+
return say("only ~ for your own home folder works here, like ~/code/your-repo", 400);
|
|
528
535
|
const decidedOn = identities.generation();
|
|
529
536
|
const resolved = asked === "" ? null : await identities.resolveNow(asked);
|
|
530
537
|
if (resolved === "no-answer") {
|
|
531
|
-
return
|
|
538
|
+
return say("that folder didn't answer — it may be on a drive that's disconnected, or waiting on macOS; try again in a moment", 503);
|
|
532
539
|
}
|
|
533
540
|
const canonical = resolved;
|
|
534
541
|
if (canonical === null) {
|
|
535
|
-
return
|
|
542
|
+
return say(asked === "" ? "enter the path of a git repository" : `${shortPathOf(resolve(asked))} isn't a folder on this computer`, 400);
|
|
536
543
|
}
|
|
544
|
+
let target = canonical;
|
|
545
|
+
let outside = false;
|
|
537
546
|
if (!(await authorizedProject(liveCeiling(), canonical))) {
|
|
538
|
-
|
|
547
|
+
const roots = ceiling.roots;
|
|
548
|
+
const outsideWords = roots.length === 0 ? "that folder isn't inside a projects folder" : `that folder isn't inside ${roots.map(shortPathOf).join(" or ")}`;
|
|
549
|
+
if (at !== "path" || who.role !== "approver" || who.authority !== "full" || store.isDemo() || restricted()) {
|
|
550
|
+
return say(`${outsideWords}, and only an approver signed in with a password can add one from elsewhere`, 403);
|
|
551
|
+
}
|
|
552
|
+
const password = body.get("password") ?? "";
|
|
553
|
+
const root = await proveProjectRoot(canonical, undefined, identities.resolveNow);
|
|
554
|
+
if (!root.ok)
|
|
555
|
+
return say(root.reason === "not-git" ? "that path is not a git repository" : root.message, 400);
|
|
556
|
+
const refused = await additionRefusal(root.repo);
|
|
557
|
+
if (refused !== null)
|
|
558
|
+
return say(refused.words, refused.status);
|
|
559
|
+
if (password === "") {
|
|
560
|
+
const chrome = chromeFor(who.session.project, "projects");
|
|
561
|
+
return void sendScreen(response, 200, outsideAddPage(chrome, { name: projectName(root.repo), path: root.repo }));
|
|
562
|
+
}
|
|
563
|
+
if (!typedPasswordNow(authenticateCredential(who, password)))
|
|
564
|
+
return say("that password didn't match", 403);
|
|
565
|
+
target = root.repo;
|
|
566
|
+
outside = true;
|
|
539
567
|
}
|
|
540
|
-
|
|
541
|
-
|
|
568
|
+
else {
|
|
569
|
+
if (!(await isGitRepo(canonical)))
|
|
570
|
+
return say("that path is not a git repository", 400);
|
|
571
|
+
const known = liveCeiling().repos.includes(canonical) || store.listProjects().some(one => one.path === canonical);
|
|
572
|
+
if (!known) {
|
|
573
|
+
const root = await proveProjectRoot(canonical, undefined, identities.resolveNow);
|
|
574
|
+
if (!root.ok)
|
|
575
|
+
return say(root.reason === "not-git" ? "that path is not a git repository" : root.message, 400);
|
|
576
|
+
const refused = await additionRefusal(root.repo, true);
|
|
577
|
+
if (refused !== null)
|
|
578
|
+
return say(refused.words, refused.status);
|
|
579
|
+
}
|
|
542
580
|
}
|
|
543
|
-
if (!visible(canonical)) {
|
|
544
|
-
return
|
|
581
|
+
if (!outside && !visible(canonical)) {
|
|
582
|
+
return say("That project is outside your access.", 403);
|
|
545
583
|
}
|
|
546
584
|
if (identities.generation() !== decidedOn)
|
|
547
|
-
return
|
|
548
|
-
const stillAllowed = (repo) => identities.generation() === decidedOn &&
|
|
549
|
-
|
|
585
|
+
return say("a project folder changed while this was being checked — try again", 409);
|
|
586
|
+
const stillAllowed = (repo) => identities.generation() === decidedOn && (outside
|
|
587
|
+
? repo === target && store.accountOf(who.name)?.revokedAt === null && store.accountOf(who.name)?.role === "approver" && store.accountOf(who.name)?.generation === who.session.generation && store.accountCanAccess(who.name, repo)
|
|
588
|
+
: visible(repo));
|
|
589
|
+
const admitted = await admitProject(store, { registryFile: options.registryPath ?? null, path: target, actor: { label: who.name, origin: "console" }, now, stillAllowed, resolveFolder: identities.resolveNow });
|
|
550
590
|
if (!admitted.ok) {
|
|
551
|
-
return
|
|
591
|
+
return say(admitted.reason === "not-git" ? "that path is not a git repository" : `that project is valid, but it could not be added — ${admitted.message}`, admitted.reason === "moved" ? 409 : 400);
|
|
552
592
|
}
|
|
553
593
|
if (!stillAllowed(admitted.repo))
|
|
554
|
-
return
|
|
594
|
+
return say("a project folder changed while this was being checked — try again", 409);
|
|
595
|
+
if (outside) {
|
|
596
|
+
outsideAdmissions.admit(admitted.repo);
|
|
597
|
+
try {
|
|
598
|
+
store.recordAction({ at: now.toISOString(), actor: who.name, repo: admitted.repo, taskId: null, runId: null, action: PROJECT_ADDED_OUTSIDE, outcome: "added", source: "access", detail: "outside the projects folder, with a password typed now" });
|
|
599
|
+
}
|
|
600
|
+
catch { }
|
|
601
|
+
}
|
|
555
602
|
deletedRepos.delete(admitted.repo);
|
|
556
603
|
who.session.project = admitted.repo;
|
|
557
604
|
who.session.projectRevision++;
|
|
558
|
-
return redirect(response,
|
|
605
|
+
return redirect(response, back);
|
|
559
606
|
}
|
|
560
607
|
async function fleetRegister(ctx) {
|
|
561
608
|
const { who, request, response, posted, now } = ctx;
|
|
@@ -608,7 +655,7 @@ export function createPagesHandlers(runtime) {
|
|
|
608
655
|
if (process.platform === "win32")
|
|
609
656
|
return refuse(response, who, 403, "adding from GitHub is not supported on Windows yet");
|
|
610
657
|
if (ceiling.roots.length === 0)
|
|
611
|
-
return projectsScreen(response, who, "
|
|
658
|
+
return projectsScreen(response, who, "cloning from GitHub needs a projects folder to clone into, and this Toolroll has none", 400, "/", "link");
|
|
612
659
|
const shape = parseGithubRepo(body.get("repo") ?? "");
|
|
613
660
|
if (!shape.ok)
|
|
614
661
|
return projectsScreen(response, who, shape.problem, 400, "/", "link");
|
|
@@ -660,7 +707,7 @@ export function createPagesHandlers(runtime) {
|
|
|
660
707
|
if (process.platform === "win32")
|
|
661
708
|
return refuse(response, who, 403, "adding from GitHub is not supported on Windows yet");
|
|
662
709
|
if (ceiling.roots.length === 0)
|
|
663
|
-
return projectsScreen(response, who, "
|
|
710
|
+
return projectsScreen(response, who, "cloning from GitHub needs a projects folder to clone into, and this Toolroll has none", 400, "/", "clone");
|
|
664
711
|
const password = body.get("token") ?? "";
|
|
665
712
|
if (!authenticateApprover(who, password).ok) {
|
|
666
713
|
return projectsScreen(response, who, "cloning takes your password, typed again", 403, "/", "clone");
|
|
@@ -735,7 +782,7 @@ export function createPagesHandlers(runtime) {
|
|
|
735
782
|
return null;
|
|
736
783
|
}
|
|
737
784
|
}
|
|
738
|
-
async function projectsScreen(response, who, problem, status, returnTo = "/", problemAt = null) {
|
|
785
|
+
async function projectsScreen(response, who, problem, status, returnTo = "/", problemAt = null, typed = "") {
|
|
739
786
|
const now = clock();
|
|
740
787
|
const { recent, candidates } = visibleProjects();
|
|
741
788
|
const open = who.via === "cookie" ? who.session.project : null;
|
|
@@ -748,9 +795,7 @@ export function createPagesHandlers(runtime) {
|
|
|
748
795
|
: ceiling.roots.length === 0
|
|
749
796
|
? {
|
|
750
797
|
enabled: false,
|
|
751
|
-
why:
|
|
752
|
-
? "Choose a projects folder once: toolroll up --project-root <dir>"
|
|
753
|
-
: "choose which folder this server may use with --project-root <dir>",
|
|
798
|
+
why: "Cloning from GitHub needs a projects folder to clone into, and this Toolroll has none.",
|
|
754
799
|
}
|
|
755
800
|
: { enabled: true, roots: ceiling.roots, localOwner: who.authority !== "full", record: [...(who.session.onboard?.entries() ?? [])][0] ?? null };
|
|
756
801
|
const peeks = {};
|
|
@@ -761,6 +806,11 @@ export function createPagesHandlers(runtime) {
|
|
|
761
806
|
return sendScreen(response, status, projectsPage(chromeFor(open, "projects"), {
|
|
762
807
|
recent, candidates, open, problem, problemAt, onboard: onboardState, peeks, returnTo,
|
|
763
808
|
browsable: !restricted() && (ceiling.roots.length > 0 || unscopedMode),
|
|
809
|
+
local: {
|
|
810
|
+
pick: who.via === "cookie" && who.role === "approver" && !restricted(),
|
|
811
|
+
outside: who.via === "cookie" && who.role === "approver" && who.authority === "full" && !store.isDemo() && !restricted() && !unscopedMode,
|
|
812
|
+
pathValue: typed,
|
|
813
|
+
},
|
|
764
814
|
}));
|
|
765
815
|
}
|
|
766
816
|
async function projectFound(ctx, page) {
|
|
@@ -1021,6 +1071,7 @@ export function createPagesHandlers(runtime) {
|
|
|
1021
1071
|
"fleet.retire": fleetRetire,
|
|
1022
1072
|
"projects.onboard-preview": onboardPreview,
|
|
1023
1073
|
"projects.onboard-confirm": onboardConfirm,
|
|
1074
|
+
"projects.pick": projectsPick,
|
|
1024
1075
|
}, {
|
|
1025
1076
|
"edge.healthz": healthzEdge,
|
|
1026
1077
|
"edge.instance": instanceEdge,
|
|
@@ -1050,5 +1101,108 @@ export function createPagesHandlers(runtime) {
|
|
|
1050
1101
|
return { ...releaseAsks(store, now, access, project, approver), flows: flowAsks(store, consoleProjects(), { name: who.name, approver }, project),
|
|
1051
1102
|
setup: setupAsks(steps, approver) };
|
|
1052
1103
|
}
|
|
1104
|
+
function toolrollStateFolders(home) {
|
|
1105
|
+
const base = configBase(process.env, home);
|
|
1106
|
+
return [...new Set([
|
|
1107
|
+
options.configDir, options.registryPath === undefined ? undefined : dirname(options.registryPath), evidenceRoot, options.poolRoot, options.toolHome,
|
|
1108
|
+
...NAMES.map(name => join(base, name)), ...NAMES.map(name => join(home, `.${name}`)),
|
|
1109
|
+
].filter((one) => typeof one === "string" && one !== "").map(one => resolve(one)))];
|
|
1110
|
+
}
|
|
1111
|
+
const lookOptions = () => ({ home: homedir(), ...(options.folderLook === undefined ? {} : { runner: options.folderLook }), ...(options.folderLookMs === undefined ? {} : { deadlineMs: options.folderLookMs }) });
|
|
1112
|
+
async function widenFacts(path) {
|
|
1113
|
+
const home = homedir();
|
|
1114
|
+
const protect = toolrollStateFolders(home);
|
|
1115
|
+
const looked = await folderFacts(path, comparisonPaths(home, protect), lookOptions());
|
|
1116
|
+
if (!looked.ok)
|
|
1117
|
+
return { ok: false, words: looked.why === "no-answer" ? "That folder didn't answer. It may be on a drive that's disconnected, or waiting on macOS. Try again in a moment." : "That folder couldn't be read." };
|
|
1118
|
+
const facts = comparisonsOf(looked.value.compare, protect.length);
|
|
1119
|
+
if (facts.home.kind !== "found")
|
|
1120
|
+
return { ok: false, words: "Your home folder couldn't be read. Try again in a moment." };
|
|
1121
|
+
const protectedReal = [];
|
|
1122
|
+
for (const one of facts.protectedDirs) {
|
|
1123
|
+
if (one.kind === "unreadable")
|
|
1124
|
+
return { ok: false, words: "One of Toolroll's own folders couldn't be read, so nothing here can be checked. Try again in a moment." };
|
|
1125
|
+
protectedReal.push(one.kind === "found" ? one.real : one.path);
|
|
1126
|
+
}
|
|
1127
|
+
return { ok: true, target: looked.value.target, home: facts.home, facts, protectedReal };
|
|
1128
|
+
}
|
|
1129
|
+
async function additionRefusal(repo, insideRoot = false) {
|
|
1130
|
+
const seen = await widenFacts(repo);
|
|
1131
|
+
if (!seen.ok)
|
|
1132
|
+
return { words: seen.words, status: 503 };
|
|
1133
|
+
if (seen.target.kind !== "found" || !seen.target.dir)
|
|
1134
|
+
return { words: "that path is not a git repository", status: 400 };
|
|
1135
|
+
const refusal = folderRefusal("repo", seen.target, insideRoot ? { ...seen.facts, tops: [], trees: [] } : seen.facts);
|
|
1136
|
+
if (refusal !== null)
|
|
1137
|
+
return { words: refusal, status: 400 };
|
|
1138
|
+
if (process.getuid !== undefined && seen.target.uid !== process.getuid())
|
|
1139
|
+
return { words: `${shortPathOf(repo)} must be a repository you own`, status: 403 };
|
|
1140
|
+
if (seen.target.real !== repo)
|
|
1141
|
+
return { words: `use the folder's own name: ${shortPathOf(seen.target.real)}`, status: 400 };
|
|
1142
|
+
return null;
|
|
1143
|
+
}
|
|
1144
|
+
async function pickerScreen(ctx) {
|
|
1145
|
+
const { url, who, response } = ctx;
|
|
1146
|
+
const chrome = chromeFor(who.via === "cookie" ? who.session.project : null, "projects");
|
|
1147
|
+
const back = ["/projects", "Projects"];
|
|
1148
|
+
const inside = (one, root) => one === root || one.startsWith(`${root}/`);
|
|
1149
|
+
const base = { problem: url.searchParams.get("problem"), said: url.searchParams.get("said"), back };
|
|
1150
|
+
const seenHome = await widenFacts(homedir());
|
|
1151
|
+
if (!seenHome.ok) {
|
|
1152
|
+
return sendScreen(response, 200, folderPickerPage(chrome, { ...base, at: null, entries: [], shortcuts: [], chosen: null, lookProblem: seenHome.words }));
|
|
1153
|
+
}
|
|
1154
|
+
const home = seenHome.home.real;
|
|
1155
|
+
const roots = [home, ...ceiling.roots.filter(root => !inside(root, home) && !inside(home, root))];
|
|
1156
|
+
const hrefOf = (path) => `/projects/pick?at=${encodeURIComponent(path)}`;
|
|
1157
|
+
const fallback = ceiling.roots[0] ?? home;
|
|
1158
|
+
const expanded = expandHomePath((url.searchParams.get("at") ?? "").trim(), home);
|
|
1159
|
+
const spelled = expanded === null || !expanded.startsWith("/") ? fallback : resolve(expanded);
|
|
1160
|
+
const start = roots.some(root => inside(spelled, root)) ? spelled : fallback;
|
|
1161
|
+
const listOptions = { ...lookOptions(), home, native: true };
|
|
1162
|
+
const protectedDirs = seenHome.protectedReal;
|
|
1163
|
+
const hiddenBelow = (path) => { const root = roots.find(one => inside(path, one)); return root !== undefined && path.slice(root.length).split("/").some(name => name.startsWith(".")); };
|
|
1164
|
+
const kept = (path) => roots.some(root => inside(path, root)) && !protectedDirs.some(dir => inside(path, dir)) && !hiddenBelow(path);
|
|
1165
|
+
const looked = await listFolder(start, roots, listOptions);
|
|
1166
|
+
const at = looked.ok ? looked.value.at : null;
|
|
1167
|
+
if (!looked.ok || at === null || !kept(at)) {
|
|
1168
|
+
const lookProblem = looked.ok ? "This folder couldn't be read." : looked.why === "no-answer" ? "This folder didn't answer. It may be on a drive that's disconnected, or waiting on macOS. Try again in a moment." : "This folder couldn't be read.";
|
|
1169
|
+
return sendScreen(response, 200, folderPickerPage(chrome, { ...base, at: null, entries: [], shortcuts: [{ label: "Home folder", href: hrefOf(home) }], chosen: null, lookProblem }));
|
|
1170
|
+
}
|
|
1171
|
+
const registered = new Set(store.listProjects().filter(one => visible(one.path)).map(one => one.path));
|
|
1172
|
+
const entries = looked.value.entries.filter(one => kept(one.path))
|
|
1173
|
+
.sort((a, b) => Number(b.git) - Number(a.git) || a.name.localeCompare(b.name)).slice(0, 200)
|
|
1174
|
+
.map(one => ({ name: one.name, git: one.git, registered: registered.has(one.path), href: hrefOf(one.path) }));
|
|
1175
|
+
const root = roots.filter(one => inside(at, one)).sort((a, b) => b.length - a.length)[0] ?? home;
|
|
1176
|
+
const parts = at === root ? [] : at.slice(root.length + 1).split("/");
|
|
1177
|
+
const crumbs = [{ label: root === home ? "~" : shortPathOf(root), href: at === root ? null : hrefOf(root) },
|
|
1178
|
+
...parts.map((part, index) => ({ label: part, href: index === parts.length - 1 ? null : hrefOf(`${root}/${parts.slice(0, index + 1).join("/")}`) }))];
|
|
1179
|
+
const up = at === root ? null : hrefOf(at.slice(0, at.lastIndexOf("/")) || root);
|
|
1180
|
+
const homeLook = at === home ? looked : await listFolder(home, roots, listOptions);
|
|
1181
|
+
const homeNames = new Set(homeLook.ok ? homeLook.value.entries.map(one => one.name) : []);
|
|
1182
|
+
const shortcuts = [
|
|
1183
|
+
...(at === home ? [] : [{ label: "Home folder", href: hrefOf(home) }]),
|
|
1184
|
+
...["Developer", "Documents", "code", "Projects"].filter(name => homeNames.has(name) && `${home}/${name}` !== at).map(name => ({ label: `~/${name}`, href: hrefOf(`${home}/${name}`) })),
|
|
1185
|
+
...ceiling.roots.filter(one => one !== at && !["Developer", "Documents", "code", "Projects"].some(name => one === `${home}/${name}`)).map(one => ({ label: shortPathOf(one), href: hrefOf(one) })),
|
|
1186
|
+
];
|
|
1187
|
+
let chosen = null;
|
|
1188
|
+
if (at !== home) {
|
|
1189
|
+
const proved = await proveProjectRoot(at, undefined, identities.resolveNow);
|
|
1190
|
+
if (proved.ok && proved.repo === at) {
|
|
1191
|
+
const name = projectName(at);
|
|
1192
|
+
const inCeiling = await authorizedProject(liveCeiling(), at);
|
|
1193
|
+
const refused = registered.has(at) && inCeiling ? null : await additionRefusal(at, inCeiling);
|
|
1194
|
+
const refusal = refused === null ? null : refused.words;
|
|
1195
|
+
const may = who.via === "cookie" && who.role === "approver" && who.authority === "full" && !store.isDemo() && !restricted();
|
|
1196
|
+
chosen = pickRepoChosen({ name, path: at, refusal, state: registered.has(at) && inCeiling ? "open" : inCeiling ? "inside" : may ? "outside" : "blocked" });
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return sendScreen(response, 200, folderPickerPage(chrome, { ...base, at: { shown: shortPathOf(at), crumbs, up }, entries, shortcuts, chosen, lookProblem: null }));
|
|
1200
|
+
}
|
|
1201
|
+
async function projectsPick(ctx) {
|
|
1202
|
+
if (ctx.who.via !== "cookie")
|
|
1203
|
+
return refuse(ctx.response, ctx.who, 403, "Choosing a repository is a browser session's act.", "/projects");
|
|
1204
|
+
return pickerScreen(ctx);
|
|
1205
|
+
}
|
|
1053
1206
|
return { registrations, projectsScreen };
|
|
1054
1207
|
}
|
|
1208
|
+
export const PROJECT_ADDED_OUTSIDE = "project added from outside the projects folder";
|
|
@@ -26,6 +26,7 @@ import { enrollOwnerPassword, liveInviteTerms, localOwnerBinding } from "../stor
|
|
|
26
26
|
import { KEY_FILL_SCRIPT } from "./mutation-key.js";
|
|
27
27
|
import { LOCAL_OWNER_LAPSED } from "../local-owner.js";
|
|
28
28
|
import { withFormToken } from "./request-context.js";
|
|
29
|
+
import { loginHelpOf } from "./login-help.js";
|
|
29
30
|
import { FULL_SESSION, SESSION_COOKIE, SIGN_IN_LINK_PATH } from "./session.js";
|
|
30
31
|
import { setupCodeMatches, signupCookie, signupFromHere } from "./signup-gate.js";
|
|
31
32
|
const AUTH_TIME_SKEW_MS = 60_000;
|
|
@@ -235,7 +236,7 @@ export function createPeopleHandlers(runtime) {
|
|
|
235
236
|
response.setHeader("Referrer-Policy", "same-origin");
|
|
236
237
|
return page(response, 200, signupPage(null, runtime.setupAttemptsLeft));
|
|
237
238
|
}
|
|
238
|
-
return page(response, 200,
|
|
239
|
+
return page(response, 200, loginWith(store, fromThisComputer(ctx.request), null, loginReturn(url.searchParams.get("return")), ssoOffer()));
|
|
239
240
|
}
|
|
240
241
|
async function signInLink(ctx) {
|
|
241
242
|
const { url, request, response } = ctx;
|
|
@@ -246,16 +247,16 @@ export function createPeopleHandlers(runtime) {
|
|
|
246
247
|
response.setHeader("Referrer-Policy", "no-referrer");
|
|
247
248
|
if (!fromThisComputer(request)) {
|
|
248
249
|
recordSignIn(held?.account ?? "unknown account", "sign-in refused", "one-time link", "opened from another device");
|
|
249
|
-
return page(response, 403,
|
|
250
|
+
return page(response, 403, loginWith(store, fromThisComputer(ctx.request), "That sign-in link works only in a browser on the computer running Toolroll. Sign in with your password.", "/chat", ssoOffer()));
|
|
250
251
|
}
|
|
251
252
|
if (held === undefined || held.expires < Date.now()) {
|
|
252
|
-
return page(response, 410,
|
|
253
|
+
return page(response, 410, loginWith(store, fromThisComputer(ctx.request), html `That sign-in link has been used or has expired. Sign in with your password, or run <code>toolroll</code> again.`, "/chat", ssoOffer()));
|
|
253
254
|
}
|
|
254
255
|
const account = store.accountOf(held.account);
|
|
255
256
|
if (account === null || account.role !== "approver" || account.revokedAt !== null)
|
|
256
|
-
return page(response, 403,
|
|
257
|
+
return page(response, 403, loginWith(store, fromThisComputer(ctx.request), "That account can't sign in here any more.", "/chat", ssoOffer()));
|
|
257
258
|
if (!passwordAllowed(held.account))
|
|
258
|
-
return page(response, 403,
|
|
259
|
+
return page(response, 403, loginWith(store, fromThisComputer(ctx.request), `Sign in with ${ssoSettings()?.label ?? "your identity provider"}.`, "/chat", ssoOffer()));
|
|
259
260
|
const id = randomBytes(32).toString("hex");
|
|
260
261
|
const keyed = keyFor(request);
|
|
261
262
|
const base = { ...arrival(request), name: held.account, csrf: randomBytes(32).toString("hex"), role: account.role, generation: account.generation, createdAt: Date.now(), sawBoardAt: null, lastSeen: Date.now(),
|
|
@@ -269,11 +270,19 @@ export function createPeopleHandlers(runtime) {
|
|
|
269
270
|
return true;
|
|
270
271
|
});
|
|
271
272
|
if (!made)
|
|
272
|
-
return page(response, 410,
|
|
273
|
+
return page(response, 410, loginWith(store, fromThisComputer(ctx.request), html `That sign-in link has been used or has expired. Run <code>toolroll</code> again to open Toolroll.`, "/chat", ssoOffer()));
|
|
273
274
|
recordSignIn(held.account, "signed in", "local link");
|
|
274
275
|
}
|
|
275
276
|
else {
|
|
276
|
-
|
|
277
|
+
const made = store.transact(() => {
|
|
278
|
+
const now = store.accountOf(held.account);
|
|
279
|
+
if (now === null || now.role !== "approver" || now.revokedAt !== null || !now.passwordSet || now.generation !== held.accountGeneration)
|
|
280
|
+
return false;
|
|
281
|
+
sessions.set(id, { ...base, generation: held.accountGeneration, ...FULL_SESSION, ...keyed.fields });
|
|
282
|
+
return true;
|
|
283
|
+
});
|
|
284
|
+
if (!made)
|
|
285
|
+
return page(response, 410, loginWith(store, fromThisComputer(ctx.request), html `That sign-in link has been used or has expired. Sign in with your password, or run <code>toolroll</code> again.`, "/chat", ssoOffer()));
|
|
277
286
|
recordSignIn(held.account, "signed in", "one-time link");
|
|
278
287
|
}
|
|
279
288
|
return signedInTo(response, keyed.key, "/chat", [`${SESSION_COOKIE}=${id}; HttpOnly; SameSite=Strict; Path=/${cookieSecure}`]);
|
|
@@ -284,15 +293,15 @@ export function createPeopleHandlers(runtime) {
|
|
|
284
293
|
const intent = url.searchParams.get("link") === "1" ? "link" : url.searchParams.get("reauth") === "1" ? "reauth" : "sign-in";
|
|
285
294
|
const returnTo = loginReturn(url.searchParams.get("return"));
|
|
286
295
|
if (settings === null)
|
|
287
|
-
return page(response, 404,
|
|
296
|
+
return page(response, 404, loginWith(store, fromThisComputer(ctx.request), "Sign-in with an identity provider isn't on.", returnTo));
|
|
288
297
|
if (intent !== "sign-in" && who?.via !== "cookie")
|
|
289
298
|
return redirect(response, loginHref(returnTo));
|
|
290
299
|
const origin = consoleOrigin(request.headers.host);
|
|
291
300
|
if (origin === null)
|
|
292
|
-
return page(response, 400,
|
|
301
|
+
return page(response, 400, loginWith(store, fromThisComputer(ctx.request), "Sign in from this computer (localhost) or from your https address.", returnTo, ssoOffer()));
|
|
293
302
|
const known = providerKnown(settings.issuer);
|
|
294
303
|
if (known === null)
|
|
295
|
-
return page(response, 503,
|
|
304
|
+
return page(response, 503, loginWith(store, fromThisComputer(ctx.request), `${settings.label} isn't answering yet. Try again in a moment.`, returnTo, ssoOffer()));
|
|
296
305
|
const found = { provider: known };
|
|
297
306
|
const visit = newOidcVisit(), redirectUri = `${origin}${SSO_CALLBACK}`;
|
|
298
307
|
for (const [key, one] of ssoVisits)
|
|
@@ -315,20 +324,20 @@ export function createPeopleHandlers(runtime) {
|
|
|
315
324
|
const { url, who, request, response } = ctx;
|
|
316
325
|
const key = url.searchParams.get("h") ?? "";
|
|
317
326
|
if (!startedHere(request, key))
|
|
318
|
-
return page(response, 400,
|
|
327
|
+
return page(response, 400, loginWith(store, fromThisComputer(ctx.request), "That sign-in was started in another browser. Sign in again from this one.", "/", ssoOffer()));
|
|
319
328
|
const handoff = ssoHandoffs.get(key);
|
|
320
329
|
ssoHandoffs.delete(key);
|
|
321
330
|
response.setHeader("Set-Cookie", signInSpent("/login/sso/finish"));
|
|
322
331
|
const settings = ssoSettings();
|
|
323
332
|
if (handoff === undefined || handoff.expires < Date.now() || settings === null)
|
|
324
|
-
return page(response, 400,
|
|
333
|
+
return page(response, 400, loginWith(store, fromThisComputer(ctx.request), "That sign-in expired. Try again.", "/", ssoOffer()));
|
|
325
334
|
const { claims } = handoff;
|
|
326
335
|
const identity = { issuer: handoff.issuer, subject: claims.sub, email: claims.email, label: settings.label };
|
|
327
336
|
if (handoff.intent === "link" || handoff.intent === "reauth") {
|
|
328
337
|
if (who?.via !== "cookie")
|
|
329
338
|
return redirect(response, loginHref(handoff.returnTo));
|
|
330
339
|
if (handoff.session === null || sessions.hashOf(who.session) !== handoff.session.hash || who.session.generation !== handoff.session.generation) {
|
|
331
|
-
return page(response, 403,
|
|
340
|
+
return page(response, 403, loginWith(store, fromThisComputer(ctx.request), `That ${settings.label} check was started by another sign-in. Start it again from this page.`, handoff.returnTo, ssoOffer()));
|
|
332
341
|
}
|
|
333
342
|
if (handoff.intent === "link") {
|
|
334
343
|
const linked = store.linkSsoIdentity(who.name, identity, clock());
|
|
@@ -339,7 +348,7 @@ export function createPeopleHandlers(runtime) {
|
|
|
339
348
|
return redirect(response, `/settings/sign-in?said=${encodeURIComponent(`This account signs in with ${settings.label} now.`)}`);
|
|
340
349
|
}
|
|
341
350
|
if (store.ssoAccount(identity.issuer, identity.subject) !== who.name)
|
|
342
|
-
return page(response, 403,
|
|
351
|
+
return page(response, 403, loginWith(store, fromThisComputer(ctx.request), `That ${settings.label} account isn't the one signed in here.`, handoff.returnTo, ssoOffer()));
|
|
343
352
|
who.session.sso = { at: handoff.checkedAt ?? 0 };
|
|
344
353
|
if (handoff.checkedAt !== null) {
|
|
345
354
|
who.session.ssoReauthAt = handoff.checkedAt;
|
|
@@ -353,7 +362,7 @@ export function createPeopleHandlers(runtime) {
|
|
|
353
362
|
const signedIn = store.signInWithSso(identity, rule === null ? null : { role: rule.role === "operator" ? "approver" : "viewer", projects: rule.projects === "all" ? null : rule.projects }, () => accountNameFor(claims, name => store.accountOf(name) !== null), clock());
|
|
354
363
|
if (!signedIn.ok) {
|
|
355
364
|
recordSignIn(store.ssoAccount(identity.issuer, identity.subject) ?? "unknown account", "sign-in refused", signedIn.reason === "no-group" ? "no matching group" : signedIn.reason);
|
|
356
|
-
return page(response, 403,
|
|
365
|
+
return page(response, 403, loginWith(store, fromThisComputer(ctx.request), signedIn.reason === "no-group" ? `Your ${settings.label} account isn't in a group that may use Toolroll. Ask whoever runs it.`
|
|
357
366
|
: signedIn.reason === "revoked" ? "This account was removed. Ask whoever runs Toolroll." : "That change would leave no one who can run this installation.", "/", ssoOffer()));
|
|
358
367
|
}
|
|
359
368
|
const account = store.accountOf(signedIn.account);
|
|
@@ -368,7 +377,7 @@ export function createPeopleHandlers(runtime) {
|
|
|
368
377
|
const { request, response } = ctx;
|
|
369
378
|
response.setHeader("Referrer-Policy", "same-origin");
|
|
370
379
|
if (options.setupCode === undefined || store.listApprovers().length > 0) {
|
|
371
|
-
return page(response, 409,
|
|
380
|
+
return page(response, 409, loginWith(store, fromThisComputer(ctx.request), "An account already exists. Sign in."));
|
|
372
381
|
}
|
|
373
382
|
if (runtime.setupAttemptsLeft <= 0) {
|
|
374
383
|
return page(response, 403, signupPage(null, 0));
|
|
@@ -399,10 +408,10 @@ export function createPeopleHandlers(runtime) {
|
|
|
399
408
|
}
|
|
400
409
|
const made = store.bootstrapApproverIfNone(name, hashPassword(password), clock());
|
|
401
410
|
if (!made.ok)
|
|
402
|
-
return page(response, 409,
|
|
411
|
+
return page(response, 409, loginWith(store, fromThisComputer(ctx.request), "An account already exists. Sign in."));
|
|
403
412
|
const authenticated = authenticateAccount(store, name, password);
|
|
404
413
|
if (authenticated === null || !authenticated.ok)
|
|
405
|
-
return page(response, 500,
|
|
414
|
+
return page(response, 500, loginWith(store, fromThisComputer(ctx.request), "The account was created, but signing in failed. Sign in with it now."));
|
|
406
415
|
const id = randomBytes(32).toString("hex");
|
|
407
416
|
const keyed = keyFor(request);
|
|
408
417
|
sessions.set(id, {
|
|
@@ -433,7 +442,7 @@ export function createPeopleHandlers(runtime) {
|
|
|
433
442
|
if (wait > 0) {
|
|
434
443
|
recordSignIn(signInActor(name), "sign-in refused", "too many tries", "from one address");
|
|
435
444
|
response.setHeader("Retry-After", String(Math.ceil(wait / 1000)));
|
|
436
|
-
return page(response, 429,
|
|
445
|
+
return page(response, 429, loginWith(store, fromThisComputer(ctx.request), `Too many sign-in attempts. Try again in ${minutesWords(wait)}.`, returnTo));
|
|
437
446
|
}
|
|
438
447
|
const authenticated = name !== null && token !== null ? authenticateAccount(store, name, token) : null;
|
|
439
448
|
if (authenticated === null || !authenticated.ok) {
|
|
@@ -441,15 +450,15 @@ export function createPeopleHandlers(runtime) {
|
|
|
441
450
|
const locked = authenticated.retryAfterMs;
|
|
442
451
|
recordSignIn(signInActor(name), "sign-in refused", "locked");
|
|
443
452
|
response.setHeader("Retry-After", String(Math.ceil(locked / 1000)));
|
|
444
|
-
return page(response, 429,
|
|
453
|
+
return page(response, 429, loginWith(store, fromThisComputer(ctx.request), `Too many wrong passwords. Try again in ${minutesWords(locked)}.`, returnTo));
|
|
445
454
|
}
|
|
446
455
|
signInBudget.failed(source, at);
|
|
447
456
|
recordSignIn(signInActor(name), "sign-in refused", "wrong password");
|
|
448
|
-
return page(response, 403,
|
|
457
|
+
return page(response, 403, loginWith(store, fromThisComputer(ctx.request), "wrong username or password", returnTo, ssoOffer()));
|
|
449
458
|
}
|
|
450
459
|
if (!passwordAllowed(name)) {
|
|
451
460
|
recordSignIn(name, "sign-in refused", "provider only");
|
|
452
|
-
return page(response, 403,
|
|
461
|
+
return page(response, 403, loginWith(store, fromThisComputer(ctx.request), `Sign in with ${ssoSettings()?.label ?? "your identity provider"}.`, returnTo, ssoOffer()));
|
|
453
462
|
}
|
|
454
463
|
recordSignIn(name, "signed in", "browser");
|
|
455
464
|
const id = randomBytes(32).toString("hex");
|
|
@@ -573,7 +582,7 @@ export function createPeopleHandlers(runtime) {
|
|
|
573
582
|
return true;
|
|
574
583
|
}
|
|
575
584
|
async function ssoCallback(request, response, url) {
|
|
576
|
-
const back = (words) => page(response, 400,
|
|
585
|
+
const back = (words) => page(response, 400, loginWith(store, fromThisComputer(request), words, "/", ssoOffer()));
|
|
577
586
|
const state = url.searchParams.get("state") ?? "";
|
|
578
587
|
if (!startedHere(request, state))
|
|
579
588
|
return back("That sign-in was started in another browser. Sign in again from this one.");
|
|
@@ -592,7 +601,7 @@ export function createPeopleHandlers(runtime) {
|
|
|
592
601
|
if (!token.ok)
|
|
593
602
|
return back(token.said);
|
|
594
603
|
if (!adapterPolicy({ caller: "service", capability: "none" }).ok)
|
|
595
|
-
return page(response, 403,
|
|
604
|
+
return page(response, 403, loginWith(store, fromThisComputer(request), "This sign-in is not allowed."));
|
|
596
605
|
const verified = await verifyIdToken(token.idToken, held.provider, settings, held.visit.nonce, clock(), fetcher);
|
|
597
606
|
if (!verified.ok) {
|
|
598
607
|
logEvent("warn", "sso.refused", { reason: verified.said });
|
|
@@ -818,3 +827,6 @@ export function createPeopleHandlers(runtime) {
|
|
|
818
827
|
});
|
|
819
828
|
return { registrations, takeJoinAttempt, ssoCallback, readAccessForm };
|
|
820
829
|
}
|
|
830
|
+
function loginWith(store, here, problem, returnTo = "/", sso = null) {
|
|
831
|
+
return loginPage(problem, returnTo, sso, loginHelpOf(store, { here }));
|
|
832
|
+
}
|
|
@@ -55,7 +55,19 @@ function expiryWords(iso) {
|
|
|
55
55
|
return iso.slice(0, 16).replace("T", " ");
|
|
56
56
|
return at.toLocaleString("en-GB", { weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" });
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
function loginFoot(sso, help) {
|
|
59
|
+
const invite = html `No account? Ask whoever runs this Toolroll for an invite link.`;
|
|
60
|
+
if (sso !== null || help.kind === "none")
|
|
61
|
+
return invite;
|
|
62
|
+
const reset = html `<code class="k-nowrap">toolroll password reset</code>`;
|
|
63
|
+
const forgot = help.kind === "local"
|
|
64
|
+
? html `Signing in without a password works only on the computer running Toolroll. There, run <code class="k-nowrap">toolroll open --web</code>.${help.passwordSet !== false ? html ` Forgot your password? Run ${reset} there.` : ""}`
|
|
65
|
+
: help.savedAt === null
|
|
66
|
+
? html `Forgot your password? Run ${reset} on the computer running Toolroll.`
|
|
67
|
+
: html `Forgot your password? On the computer running Toolroll, your first password is saved in <code data-saved-login>${joinHtml(help.savedAt.split("/").map((part, index) => index === 0 ? html `${part}` : html `/<wbr>${part}`))}</code> (until you change it). Changed it and forgot? Run ${reset} there.`;
|
|
68
|
+
return html `<span data-login-help="${help.kind}">${forgot}</span><br>${invite}`;
|
|
69
|
+
}
|
|
70
|
+
export function loginPage(problem, returnTo = "/", sso = null, help = { kind: "password", savedAt: null }) {
|
|
59
71
|
const form = postForm("/login", joinHtml([
|
|
60
72
|
outField({ id: "login-name", label: "Username", name: "name", attrs: { autocomplete: "username", autocapitalize: "none", spellcheck: "false", required: true, ...(sso === null ? { autofocus: true } : {}) } }),
|
|
61
73
|
outField({ id: "login-password", label: "Password", name: "token", type: "password", attrs: { autocomplete: "current-password" } }),
|
|
@@ -70,7 +82,7 @@ export function loginPage(problem, returnTo = "/", sso = null) {
|
|
|
70
82
|
]);
|
|
71
83
|
return shell("Sign in · Toolroll", outPage({
|
|
72
84
|
brand: BRAND_HTML, brandHref: "/login", title: "Sign in", body,
|
|
73
|
-
foot:
|
|
85
|
+
foot: loginFoot(sso, help),
|
|
74
86
|
}), { nav: false });
|
|
75
87
|
}
|
|
76
88
|
export function reconnectPage(problem, returnTo, how) {
|