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

[change] Do not send new SMS unless needed #656 #665

Merged
merged 3 commits into from
Jun 29, 2023

Conversation

pandafy
Copy link
Member

@pandafy pandafy commented Jun 24, 2023

Closes #656

nemesifier pushed a commit to openwisp/openwisp-radius that referenced this pull request Jun 26, 2023
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

Looks good and works as expected during testing!
I have 2 requests.

1. Backward Compatibility

I think that if we try to use this version of OWLP with an older version of OpenWISP Radius, the SMS token verification process will break because the active token view is not available.

Can you please make the code resilient to this failure? Here's how it could work:

  • if the nodeJS backend gets 404 from openwisp-radius, it shall forward the 404
  • if the frontend JS code gets 404, it assumes it has to send a new verification code (old behavior is kept for backward compatibility).

What do you think?

2. I found a React Warning during testing

Can you see if you get this warning when reloading the phone number verification page?

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
    in Status (created by Connect(Status))
    in Connect(Status) (created by OrganizationWrapper)
    in Suspense (created by OrganizationWrapper)

If you do, can you look into whether this was there since before or not? If not please fix it, if it was already there please create an issue.

// return 404 for invalid organization slug or org not listed in config
if (!validSlug) {
res.status(404).type("application/json").send({
response_code: "INTERNAL_SERVER_ERROR",
Copy link
Member

Choose a reason for hiding this comment

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

Probably we don't want to send "INTERNAL_SERVER_ERROR" here but something different.
If this case is triggered, we must make sure the old behavior of sending the SMS token anyway is not triggered in this case because we know it's not needed.

Comment on lines 192 to 200
if (error.response && error.response.status === 404) {
// This is kept for backward compatibility with older versions of OpenWISP RADIUS
// that does not have API endpoint for checking phone token status.
return false;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

The backend was already returning 404 response when the API endpoint is not present in OpenWISP RADIUS. I added this handling in the frontend.

@pandafy
Copy link
Member Author

pandafy commented Jun 28, 2023

2. I found a React Warning during testing

Can you see if you get this warning when reloading the phone number verification page?

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
    in Status (created by Connect(Status))
    in Connect(Status) (created by OrganizationWrapper)
    in Suspense (created by OrganizationWrapper)

If you do, can you look into whether this was there since before or not? If not please fix it, if it was already there please create an issue.

This bug is also present on the master branch. I opened #668

@pandafy pandafy force-pushed the issues/656-do-not-send-sms branch from 590b6b9 to 3b4c660 Compare June 28, 2023 13:03
@pandafy pandafy force-pushed the issues/656-do-not-send-sms branch from 3b4c660 to d53b576 Compare June 28, 2023 15:22
}
return org.slug === reqOrg;
});
// Return 401 for invalid organization slug or org not listed in config.
Copy link
Member

Choose a reason for hiding this comment

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

Is this comment right? Is 401 used here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Earlier, I used 401 here. But, that would not be correct. So, I updated the code to return 404 and used a different response code.

@nemesifier nemesifier merged commit 51d2711 into master Jun 29, 2023
@nemesifier nemesifier deleted the issues/656-do-not-send-sms branch June 29, 2023 14:39
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.

[change] Do not send new SMS unless needed
2 participants