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

JSON Response with status code for Admins Verifying Accounts, especially for already verified users #306

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ochan1
Copy link
Contributor

@ochan1 ochan1 commented Nov 5, 2021

This adds backend logic to allow for processing one-by-one accounts approved for verification

The original code returns an HTML for when the user is already successfully verified, but it can cause the Cloud Request code to error when the verify_user is called using the Cloud.prototype.request in Snap!'s cloud.js since it assumes a JSON request

This modification returns an OK JSON when an admin with a token of 0 approves a user

An additional field showing the status code of the verification is used to allow for messages to be shown why a user has failed verification upon detection of a certain status code (Verified, Already Verified, or Failed Verification)

This does not preprocess users one by one but does show which users fall under each of the three categories

This was made in conjunction with snap-cloud/SnapSite#111, but this Pull Request is not dependent on that one (but the SnapSite Pull Request is dependent on this snapCloud Pull Request)


-- admins can verify people without the need of a token
if self.params.token == '0' then assert_admin(self)
if self.queried_user.verified then
return okResponseWithStatusCode('User ' .. self.queried_user.username ..
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, what's the reason for the new method, and the 'Already Verified' argument? The status_code argument of the jsonResponse method is meant to be a HTTP Status code, in this case it should always be 200.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was meant to be a message representing if the user was verified successfully or already verified, so the bulk verify can let the verifying person know who got verified or who was already verified
There isn't really a way of distinguishing between either one unless one were to use the message string, which is prone to be modified in the future since it is a message

I changed the name to make it less confusing between a Request status code and the Status of reaching this point of the code (I called it the State Message)

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.

None yet

2 participants