Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:Github ID type check #208

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions client/client-landing/services/validate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const instance: AxiosInstance = axios.create({

export const getUser = async (id: string): Promise<boolean> => {
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;
}
Expand Down
12 changes: 9 additions & 3 deletions server/githubsrm/apis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ 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()
# 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
else:
return False
else:
return False
else:
# Todo: move to github apis after discussion on porting
# Used for existing projects.
Expand Down