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

Feat/add jwt to authjs #215

Merged
merged 12 commits into from
Aug 30, 2023
Merged

Feat/add jwt to authjs #215

merged 12 commits into from
Aug 30, 2023

Conversation

SEBRATHEZEBRA
Copy link
Contributor

No description provided.

@SEBRATHEZEBRA SEBRATHEZEBRA linked an issue Aug 25, 2023 that may be closed by this pull request
5 tasks
@github-actions
Copy link
Contributor

github-actions bot commented Aug 25, 2023

Risk Level 2 - /home/runner/work/code-review-gpt/code-review-gpt/services/web-app/src/app/profile/page.tsx

The changes in the profile page have a moderate risk to the code base. The added code retrieves the user data from the server using the 'getUser' endpoint and displays it on the page. No potential bugs or readability issues were found. However, it would be better to handle the case when the user data cannot be retrieved separately from the case when the user is not logged in.


Risk Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/services/web-app/src/lib/hooks/useAxios.tsx

  • Potential bug: The getSession function is called without any arguments. This may cause an error or unexpected behavior. Please ensure that the getSession function is called correctly.
  • Readability improvement: The code can be made more readable by providing a type annotation for the session variable.
  • SOLID principle: The code violates the Single Responsibility Principle (SRP) by combining the logic of getting the session and setting the authorization header in the same function. It would be better to separate these concerns into separate functions or modules.

Example code snippet for readability improvement:

const session: Session | null = getSession();

Example code snippet for separating concerns:

const setAuthorizationHeader = (config: AxiosRequestConfig, session: Session) => {
  config.headers.Authorization = session.token;
  return config;
};

axiosInstance.interceptors.request.clear();
axiosInstance.interceptors.request.use((config) => setAuthorizationHeader(config, session));

Risk Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/services/core/functions/update-user/index.ts

The changes in the update-user function have a moderate risk to the code base. The added code retrieves the 'userId' from the request body and uses it to update the user in the UserEntity. No potential bugs or readability issues were found. However, it would be better to handle the case when 'apiKey' or 'userId' is not provided separately from the error when updating the user.


🔍🔧👍


Powered by Code Review GPT

@github-actions
Copy link
Contributor

github-actions bot commented Aug 25, 2023

Test results summary:

✅ [PASS] - Test case: Bad variable name
❌ [FAIL] - Test case: Exposed secret
✅ [PASS] - Test case: Too many nested loops
⚠️ [WARN] - Test case: Unawaited Promise

SUMMARY: ✅ PASS: 2 - ⚠️ WARN: 1 - ❌ FAIL: 1


Tests Powered by Code Review GPT

@SEBRATHEZEBRA SEBRATHEZEBRA marked this pull request as ready for review August 29, 2023 14:52
Copy link
Contributor

@lizacullis lizacullis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also please check the Update-User and make sure that that also has the email changed to userId.


if (email === undefined) {
if (userId === undefined) {
return formatResponse("Please provide the email of the user you wish to get.", 400)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return formatResponse("Please provide the email of the user you wish to get.", 400)
return formatResponse("Please provide the userId of the user you wish to get.", 400)

autoDeleteObjects: !isProduction(),
// autoDeleteObjects: !isProduction(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattzcarey Seb and I chatted about this. Adding this autoDeleteObjects thing is a bit broken, and it doesn't allow you to tear down your stack (you will see a couple of stacks already have DeleteFailed). So we have both commented this out for now. Might be a good things to investigate!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

Comment on lines 28 to 26
console.log("Failed to getUser");
console.log("Failed to getUser, error -> ", err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

export const BASE_URL = "https://mylf3hxjs8.execute-api.eu-west-2.amazonaws.com/prod";
export const BASE_URL = "https://2dw4kjr0a2.execute-api.eu-west-2.amazonaws.com/prod";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to chat about how to better do this. Not now's problem, but would be nice if this could be gotten from aws or something!

Copy link
Owner

@mattzcarey mattzcarey Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will use the staging URL here in future. That is deployed.

axiosInstance.interceptors.request.clear();
axiosInstance.interceptors.request.use(
(config) => {
config.headers.Authorization = (session as Session).token;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it

@SEBRATHEZEBRA SEBRATHEZEBRA merged commit b967671 into main Aug 30, 2023
@SEBRATHEZEBRA SEBRATHEZEBRA deleted the feat/add-jwt-authjs branch August 30, 2023 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NOT DONE [Auth FE] AASignedInUser I generate a JWT which contains my userId
3 participants