VRMS icon indicating copy to clipboard operation
VRMS copied to clipboard

Admin Login Requires Multiple Attempts

Open plang-psm opened this issue 2 years ago • 6 comments

Dependency

  • [x] #1474
  • [ ] Retest this bug to ensure issue is still relevant before working on it.

Overview

The Admin login currently has a bug that returns a We don't recognize your email address. Please create an account. error when trying to login. Clicking login a second time without making any changes grants access. We need to ensure users are accurately being granted access with their first attempt.

Action Items

  • [ ] Check #1323 to see if any of the completed issues resolved this one. If so, close this issue.
    • [ ] Resolve the user authorization from needing two attempts to login.
  • [ ] Check off your issue on #1323
See Error screenshot

image

Resources/Instructions

  • Possible helpful paths:
  • Client folder:
    • Path: context/authContext.js Line 36
    • Path: hooks/useAuth.js

plang-psm avatar Mar 09 '23 02:03 plang-psm

@plang-psm those screenshots you took don't show which version of the site the error occured on

I have never seen it happen in local dev env

I also haven't been able to recreate it on dev.vrms.io even with inconito mode

It does definitely happen on vrms.io tho

MattPereira avatar Mar 15 '23 21:03 MattPereira

@MattPereira

These errors occurred on vrms.io.

plang-psm avatar Mar 15 '23 23:03 plang-psm

This is so weird but i've been trying to recreate the bug on Thursday March 16th on vrms.io from different browsers and devices and it doesn't seem like its occurring for the time being

I'm burnt out after a few hours on this one so I'm putting it back in the Prioritzied Backlog for now in case someone else is seeing something that I am not

MattPereira avatar Mar 16 '23 20:03 MattPereira

So the bug just happened to me dev.vrms.io today which it wasnt doing yesterday :ghost:

Both dev.vrms.io and vrms.io are deployed using the same commit

MattPereira avatar Mar 16 '23 20:03 MattPereira

Throwing this one back into the prioritized backlog until we get access to AWS.

Initial thoughts

It seems like it is hitting an error during the first login resulting in the user data to be null. This could explain why I received a null from console.logging checkUser (see the notes below).

The initial error set off a 502 error which could mean there is an issue with our AWS — we do not have access at this time see below.

If AWS is not the issue, we need to diagnose whether the checkUser or checkAuth is sending off the error.

      if (userData) {
        if (
          userData.user.accessLevel !== ADMIN &&
          userData.user.accessLevel === USER &&
          userData.user.managedProjects.length === 0
        ) {
          showError(
            "You don't have the correct access level to view the dashboard"
          );
          return;
        }

        const isAuth = await checkAuth(email, LOG_IN);
        if (isAuth) {
          history.push('/emailsent');
        } else {
          showError(
            'We don’t recognize your email address. Please, create an account.'
          );
        }
      } else {
        showError(
          'We don’t recognize your email address. Please, create an account.'
        );
      }

Some notes below.

  • Error does not occur on local but occurs on dev/prod.
  • Cannot replicate the error in local and have had trouble recreating the error in dev/prod to debug but the initial issue sent off a 502 error which could possibly mean this is a server error
    • To add to that, local does not use AWS like dev/prod. We do not have access to the correct VRMS AWS account and cannot verify this at this time.
    • Also, there has been an error with our SSL cert as of recent
  • I do recall putting a console.log on checkUser and it returned null
  • All users keep receiving a 'We don’t recognize your email address. Please, create an account.' which is thrown twice in the Auth.js file. The first is in the if(userData) using checkUser to pull the user data. The second is in the if(isAuth) which is using checkAuth to authorize a user via a boolean by checking if the user status code is equal to 200.

https://user-images.githubusercontent.com/101952500/230730448-c9d905c5-1bc6-4a4b-99bd-efe89bd28e0f.png

Resources

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/http-502-bad-gateway.html

plang-psm avatar Apr 14 '23 01:04 plang-psm

@plang-psm stashing this in questions/review until we figure out what to do next

And leaving you assigned so you get credit for your hard work whenever this is ends up closed

MattPereira avatar Apr 14 '23 03:04 MattPereira

Move this dependency

Retest this bug to ensure issue is still relevant before working on it. to the top action item

ExperimentsInHonesty avatar Mar 07 '25 00:03 ExperimentsInHonesty