From 0053e2cb8a5586e4147a3878cb337cc5b2964a3a Mon Sep 17 00:00:00 2001 From: Sudhanshu Srivastava <71897832+Codered9@users.noreply.github.com> Date: Sun, 27 Feb 2022 18:26:06 +0530 Subject: [PATCH 1/3] fix:Github ID type check --- client/client-landing/services/validate.tsx | 6 ++++-- server/githubsrm/apis/utils.py | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client/client-landing/services/validate.tsx b/client/client-landing/services/validate.tsx index 50cd7d5a..1fc6c057 100644 --- a/client/client-landing/services/validate.tsx +++ b/client/client-landing/services/validate.tsx @@ -6,8 +6,10 @@ const instance: AxiosInstance = axios.create({ export const getUser = async (id: string): Promise => { try { - await instance.get(`/users/${id}`); - return true; + const { data } = await instance.get(`/users/${id}`); + if (data.type === "User") + return true; + return false; } catch (error) { return false; } diff --git a/server/githubsrm/apis/utils.py b/server/githubsrm/apis/utils.py index 02d530e1..428032c7 100644 --- a/server/githubsrm/apis/utils.py +++ b/server/githubsrm/apis/utils.py @@ -44,9 +44,11 @@ def verify_github_details(verify_user=False, **kwargs): if verify_user: response = session.get(f"{github_api}/users/{kwargs['user_id']}") - if response.status_code == 403: - response = session.get(f"{source_route}/{kwargs['user_id']}") - return response.status_code == 200 + res = response.json() + if(res['type']=="User" and response.status_code == 200): + return response.status_code == 200 + elif(res['type']!="User" and response.status_code == 200): + return False else: # Todo: move to github apis after discussion on porting # Used for existing projects. From 993119c6a09dc069ca287738bbf61cfb1b24e8d0 Mon Sep 17 00:00:00 2001 From: Sudhanshu Srivastava <71897832+Codered9@users.noreply.github.com> Date: Wed, 27 Apr 2022 20:00:38 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=85=20Github=20ID=20Type=20Check=20if?= =?UTF-8?q?=20else=20statement.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/githubsrm/apis/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/githubsrm/apis/utils.py b/server/githubsrm/apis/utils.py index 428032c7..e6ebcada 100644 --- a/server/githubsrm/apis/utils.py +++ b/server/githubsrm/apis/utils.py @@ -45,9 +45,12 @@ def verify_github_details(verify_user=False, **kwargs): if verify_user: response = session.get(f"{github_api}/users/{kwargs['user_id']}") res = response.json() - if(res['type']=="User" and response.status_code == 200): - return response.status_code == 200 - elif(res['type']!="User" and response.status_code == 200): + if(response.status_code == 200): + if(res['type']=="User" ): + return True + else: + return False + else: return False else: # Todo: move to github apis after discussion on porting From b70486b1f3d00b10117b21230e2299e0c8a77d0c Mon Sep 17 00:00:00 2001 From: Sudhanshu Srivastava <71897832+Codered9@users.noreply.github.com> Date: Thu, 28 Apr 2022 09:35:52 +0530 Subject: [PATCH 3/3] wip Comment --- server/githubsrm/apis/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/server/githubsrm/apis/utils.py b/server/githubsrm/apis/utils.py index e6ebcada..db7df5ec 100644 --- a/server/githubsrm/apis/utils.py +++ b/server/githubsrm/apis/utils.py @@ -45,6 +45,7 @@ def verify_github_details(verify_user=False, **kwargs): if verify_user: response = session.get(f"{github_api}/users/{kwargs['user_id']}") res = response.json() + # Will send False to the frontend if server is down or User ID is not a personal id but a Organisation ID. if(response.status_code == 200): if(res['type']=="User" ): return True