From 9da6f54d763080fdb8bc27a49d58e87d203b9808 Mon Sep 17 00:00:00 2001 From: Larbi Gharib <larbi.gharib@savoirfairelinux.com> Date: Fri, 11 Sep 2020 16:13:02 -0400 Subject: [PATCH] Username lowercase ns check Change-Id: Iaeaf211b5d2e4e8e775e23cffcd784fd6411db7a --- jams-react-client/src/globalUrls.js | 2 ++ .../src/views/UserProfile/EditCreateUserProfile.js | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/jams-react-client/src/globalUrls.js b/jams-react-client/src/globalUrls.js index a19492ff..85565dc0 100644 --- a/jams-react-client/src/globalUrls.js +++ b/jams-react-client/src/globalUrls.js @@ -49,6 +49,7 @@ const api_path_delete_admin_contacts = "/api/admin/contacts"; const api_path_blueprints = "/api/admin/policy"; const api_path_get_user_profile = "/api/auth/userprofile/"; const api_path_get_ns_name_from_addr = "/api/nameserver/addr/"; +const api_path_get_ns_addr_from_name = "/api/nameserver/name/"; module.exports = { uri, @@ -100,4 +101,5 @@ module.exports = { api_path_blueprints, api_path_get_user_profile, api_path_get_ns_name_from_addr, + api_path_get_ns_addr_from_name, }; diff --git a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js index 45879b46..2548051b 100644 --- a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js +++ b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js @@ -61,7 +61,7 @@ import { api_path_post_create_user, api_path_post_create_user_profile, api_path_get_user_profile, - api_path_get_exists_user, + api_path_get_ns_addr_from_name, } from "../../globalUrls"; import dashboardStyle from "assets/jss/material-dashboard-react/views/dashboardStyle.js"; @@ -248,6 +248,7 @@ export default function EditCreateUserProfile(props) { }; const handleCreateUser = (data) => { + data.username = data.username.toLowerCase(); const body = { username: data.username, password: data.password, @@ -334,7 +335,14 @@ export default function EditCreateUserProfile(props) { const data = { username: value.toLowerCase(), }; - axios(configApiCall(api_path_get_exists_user, "GET", data, null)) + axios( + configApiCall( + api_path_get_ns_addr_from_name + data.username, + "GET", + null, + null + ) + ) .then((response) => { if (response.status === 200) { resolve(false); -- GitLab