Repository navigation
feat: say which login page the box shows, and let a session choose it - #11
Merged
Merged
Conversation
GET /v1/users/status says login_style ("classic" or "beta") to anybody,
since the login page asks before anybody signs in. PUT
/v1/users/login-style {"style": "classic"|"beta"} needs a session.
The choice is a file of its own in the user data folder; classic
removes it, so a box that never chose is as before.
inkly
approved these changes
Nov 6, 2026
inkly
left a comment
Collaborator
There was a problem hiding this comment.
Looks good. The PUT sits in the JWT-protected v1 group, the value is whitelisted on both sides, and the file path never takes user input. An old UserService with the new UI falls back to the classic page.
Two small things, non-blocking:
route/login_style_test.go:config.AppInfo.UserDataPath = t.TempDir()is never restored, so later tests in the package point at a deleted folder. The other tests uset.Cleanupfor this (v1_password_test.go,first_admin_test.go).setLoginStyle: the temp file name.newis fixed, so two PUTs at the same moment race and the secondRenamereturns a 500 that shows the path.os.CreateTempin the same folder avoids it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The opt-in for the new login page (ReCasaOS/CasaOS#84, point 2). The login page has no session to read a user's settings with, so the choice belongs to the box. The user service keeps it and tells it to anybody:
GET /v1/users/statusalso returnslogin_style:"classic"or"beta". The login page already calls it before anybody signs in.PUT /v1/users/login-stylewith{"style": "classic"}or{"style": "beta"}changes it. It needs a session, like every other setting. Any other value gets a 400 (4000).login-style, in the user data folder (/var/lib/casaos). The file is written next to its place and then renamed, so a reader never sees half a file.classicremoves the file, so a box that never chose stays as it was. A file that can't be read, or holds anything else, also means classic.The UI side is ReCasaOS/CasaOS-UI#123.
Tested:
route/login_style_test.go(status without a session; PUT without a session gets 401; bad values; beta, then classic, then classic again; a file with something else in it), and the wholego test ./.... On a Mint box (v0.5.84) with this build: status saysclassic, the PUT turns it tobeta, and the UI PR shows the new page.