Fix multi-user setup bug for invalid username/password (#2130)

* fix multiuser setup bug for invalid username/password

* handle user creation failed gracefully and delete user on fail
This commit is contained in:
Sean Hatfield 2024-08-16 12:55:14 -07:00 committed by GitHub
parent ff0605ce67
commit 1dad4d9409
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View File

@ -288,6 +288,11 @@ const MyTeam = ({ setMultiUserLoginValid, myTeamSubmitRef, navigate }) => {
onChange={handleUsernameChange}
/>
</div>
<p className=" text-white text-opacity-80 text-xs font-base">
Username must be at least 6 characters long and only contain
lowercase letters, numbers, underscores, and hyphens with no
spaces.
</p>
<div className="mt-4">
<label
htmlFor="name"
@ -306,9 +311,8 @@ const MyTeam = ({ setMultiUserLoginValid, myTeamSubmitRef, navigate }) => {
onChange={handlePasswordChange}
/>
</div>
<p className="w-96 text-white text-opacity-80 text-xs font-base">
Username must be at least 6 characters long. Password must be at
least 8 characters long.
<p className=" text-white text-opacity-80 text-xs font-base">
Password must be at least 8 characters long.
</p>
</div>
</div>

View File

@ -481,6 +481,15 @@ function systemEndpoints(app) {
password,
role: ROLES.admin,
});
if (error || !user) {
response.status(400).json({
success: false,
error: error || "Failed to enable multi-user mode.",
});
return;
}
await SystemSettings._updateSettings({
multi_user_mode: true,
limit_user_messages: false,