Skip to content

fix(users): one first account, and less said without a sign-in - #12

Merged
inkly merged 1 commit into
mainfrom
fix/register-once-and-public-routes
Nov 10, 2026
Merged

inkly merged 1 commit into
mainfrom
fix/register-once-and-public-routes

Conversation

@inkly

@inkly inkly commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Four changes to what the user service does for somebody who has not signed in. Each has a test that failed first.

Registration. A key from GET /v1/users/status creates the first account and no other: the registration is refused once an account exists, the table of keys is emptied after the first one, and a lock covers the whole registration so two keys used at the same moment make one account.

Sign-in budget. /login had one budget for everybody, so one noisy machine on the network kept the owner out. Strangers keep that shared budget, unchanged. An address a sign-in succeeded from gets a budget of its own.

GET /v1/users/image. The sign-in page needs it without a token for the avatar and the wallpaper. It now serves pictures only, by the two rules a picture gets in by (its name for an upload, its content for one taken from Files), from <UserDataPath>/<id>/ only. The folder check uses UserDataPath in place of a hard-coded /var/lib/casaos. GetImageExt closes the file it opens.

GET /v1/users/name. It moves behind the token. The dashboard does not call it.

Tests. Four new tests in route/v1_public_test.go; TestVerifyOutsideLoginLimiter and the test rig move to the new budget. go vet ./... and go test ./... -count=1 pass on my Windows machine; -race was not run there. Nothing was tried on a real box.

A key from GET /v1/users/status created an administrator for as long as
it was kept: every visit before the box was set up got one, and only the
one used was forgotten. A key now creates the first account and no other,
the table is emptied after it, and a lock covers the whole registration.

/login needs no account, and had one budget for everybody: any machine
on the network spent it and the owner could not sign in. Strangers keep
that shared budget, five tries and one a minute; an address a sign-in
succeeded from has its own.

GET /v1/users/image served any file in a user's folder, the dashboard's
settings among them. It serves pictures only, from a user's folder only,
and looks at the folder before the disk. GetImageExt closes the file it
opens.

GET /v1/users/name, the list of accounts, needs a sign-in.
@inkly
inkly marked this pull request as ready for review November 10, 2026 10:55
@inkly
inkly merged commit dfb19fe into main Nov 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant