mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 07:23:00 +00:00
Fix EditUser submit bug
This commit is contained in:
@@ -36,14 +36,7 @@ const AddUser = (props) => {
|
||||
type="checkbox"
|
||||
value=""
|
||||
id="admin-check"
|
||||
onChange={(e) =>
|
||||
// this.setState(
|
||||
// Object.assign({}, this.state, {
|
||||
// admin: e.target.checked,
|
||||
// })
|
||||
// )
|
||||
setAdmin(e.target.checked)
|
||||
}
|
||||
onChange={(e) => setAdmin(e.target.checked)}
|
||||
/>
|
||||
<span> </span>
|
||||
<label className="form-check-label">Admin</label>
|
||||
|
@@ -12,9 +12,7 @@ const withUserAPI = withProps((props) => ({
|
||||
deleteUser: (username) => jhapiRequest("/users/" + username, "DELETE"),
|
||||
failRegexEvent: () =>
|
||||
alert(
|
||||
"Removed " +
|
||||
JSON.stringify(removed_users) +
|
||||
" for either containing special characters or being too short."
|
||||
"Cannot change username - either contains special characters or is too short."
|
||||
),
|
||||
refreshUserData: () =>
|
||||
jhapiRequest("/users", "GET")
|
||||
|
@@ -79,24 +79,34 @@ const EditUser = (props) => {
|
||||
id="submit"
|
||||
className="btn btn-primary"
|
||||
onClick={() => {
|
||||
if (updatedUsername == "" && admin == has_admin) return;
|
||||
if (
|
||||
updatedUsername.length > 2 &&
|
||||
/[!@#$%^&*(),.?":{}|<>]/g.test(updatedUsername) == false
|
||||
) {
|
||||
editUser(
|
||||
username,
|
||||
updatedUsername != "" ? updatedUsername : username,
|
||||
admin
|
||||
)
|
||||
if (updatedUsername == "" && admin == has_admin) {
|
||||
return;
|
||||
} else if (updatedUsername != "") {
|
||||
if (
|
||||
updatedUsername.length > 2 &&
|
||||
/[!@#$%^&*(),.?":{}|<>]/g.test(updatedUsername) == false
|
||||
) {
|
||||
editUser(
|
||||
username,
|
||||
updatedUsername != "" ? updatedUsername : username,
|
||||
admin
|
||||
)
|
||||
.then((data) => {
|
||||
history.push("/");
|
||||
refreshUserData();
|
||||
})
|
||||
.catch((err) => {});
|
||||
} else {
|
||||
setUpdatedUsername("");
|
||||
failRegexEvent();
|
||||
}
|
||||
} else {
|
||||
editUser(username, username, admin)
|
||||
.then((data) => {
|
||||
history.push("/");
|
||||
refreshUserData();
|
||||
})
|
||||
.catch((err) => {});
|
||||
} else {
|
||||
setUpdatedUsername(null);
|
||||
failRegexEvent();
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
Reference in New Issue
Block a user