-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add post-installation redirect based on admin account status #34493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
models/user/user.go
Outdated
@@ -831,6 +831,21 @@ type CountUserFilter struct { | |||
IsActive optional.Option[bool] | |||
} | |||
|
|||
// HasUsers returns true if any user exists in the database. | |||
// It performs a much more efficient check than counting all users. | |||
func HasUsers(ctx context.Context) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to make handleUserCreated
use the same logic.
And there is no need to add "WHERE ...", just check whether any record exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a key logic in handleUserCreated
, which is to determine whether the current account is the first: CountUsers(ctx, nil) == 1
; I am not quite sure if it can be replaced with the newly added method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't speak on frontend design, but otherwise this looks good to me.
Was iffy about the HasUsers()
calls ignoring DB errors, but after further reading it seems the worst that can happen is:
- User accesses sign up page (or completes the install config if they're on the install page)
- A DB error occurs
- Server sends sign up page + the
sign_up_tip
message to the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@@ -421,6 +421,7 @@ remember_me.compromised = The login token is not valid anymore which may indicat | |||
forgot_password_title= Forgot Password | |||
forgot_password = Forgot password? | |||
need_account = Need an account? | |||
sign_up_tip = You are registering the first account in the system. Please carefully remember your username and password, as losing this information could cause significant inconvenience later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an unclear message. For example: why the "first account" is special? What "significant inconvenience" would happen? If it is not clean, it only confuses or frightens end users.
And also please review admin related bug fix: Fix last admin check when syncing users #34649 |
This PR adds a feature to direct users to appropriate pages after system installation: