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