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

Jerry - email verification admin accounts #582

Merged
merged 10 commits into from
Jan 13, 2024

Conversation

jerryren527
Copy link
Contributor

@jerryren527 jerryren527 commented Oct 24, 2023

Description

Screenshot 2023-09-28 at 8 53 11 AM

Related PRS (if any):

Main changes explained:

  • added actualEmail field to userProfile schema
  • check for Owner and Administrator roles before making request to Beta Login route
  • minor formatting fix in 'Acutal Password' label
  • added axios to package.lock (I was unable to use fetch api successfully)

How to test:

  1. check into current branch
  2. do npm install and ... to run this PR locally
  3. Follow the instructions of the front end PR #1446 (Jerry - email verification admin accounts HighestGoodNetworkApp#1446)

Note:

If anyone knows how to use Fetch API instead of Axios to successfully make the request to the Beta Login route on line 145 of src/controllers/userProfileController.js, then please do let me know. This is because we can avoid adding the additional axios library if we can use Fetch instead. Thanks!

In my latest commit, I replaced the axios call with a fetch call.

Before (with axios):

  try {
  // Log in to Beta login route using provided credentials
  let response = await axios.post(url + "login", {
    email: email,
    password: password
  })
} catch (error) {
  res.status(400).send({
    error: 'The actual email or password you provided is incorrect. Please enter the actual email and password associated with your account in the Main HGN app.',
    type: 'credentials',
  });
  return;
}

After (with fetch):

try {
  // Log in to Beta login route using provided credentials
    const response = await fetch(url + 'login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ email, password }),
  });
  if (!response.ok) {
    throw new Error('Invalid credentials');
  }
} catch (error) {
  res.status(400).send({
    error: 'The actual email or password you provided is incorrect. Please enter the actual email and password associated with your account in the Main HGN app.',
    type: 'credentials',
  });
  return;
}

Whenever an Administrator user is created, utilized newly added
'req.body.betaEmail' and 'req.body.betaPassword' to validate that the
provided email address exists in the beta database.
Use req.body.actualEmail and req.body.actualPassword on the beta login
route. If error caught, return 400 error.
In addition, removed unnecessary getEmails() and associated its route.
Checked for Owner and Administrator roles before making request to
beta login route. Made minor formatting fix in Acutal Password label.
Copy link
Contributor

@navneeeth navneeeth left a comment

Choose a reason for hiding this comment

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

Hi! Tested your changes and they LGTM! Commented a detailed review on the FE PR. Great work!

Copy link

@malikjahanzaib malikjahanzaib left a comment

Choose a reason for hiding this comment

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

Hi @jerryren527, tested this PR and it works as intended. Left detailed review on FE PR #1446. Great job!!!

@jerryren527 jerryren527 force-pushed the jerry_email_verification_admin_accounts branch from 061243b to bcf15dc Compare November 1, 2023 17:13
Removed axios from package.json. And replaced axios call with fetch call.
Copy link
Contributor

@Shuhua-L Shuhua-L left a comment

Choose a reason for hiding this comment

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

Hey @jerryren527 I’ve tested both of your PRs and they worked as expected. More details can be found in Front End PR. Nice work!

Copy link

@Alforoan Alforoan left a comment

Choose a reason for hiding this comment

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

Check my comment on fe #1446

Copy link
Contributor

@ramyaram2092 ramyaram2092 left a comment

Choose a reason for hiding this comment

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

Left feedback and the testing video on the front end PR

@one-community one-community merged commit ad98001 into development Jan 13, 2024
3 checks passed
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.

7 participants