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

Fix State Field Case Sensitivity for Ambassador Sign-Up #121

Closed
ajones620 opened this issue Sep 26, 2020 · 3 comments
Closed

Fix State Field Case Sensitivity for Ambassador Sign-Up #121

ajones620 opened this issue Sep 26, 2020 · 3 comments

Comments

@ajones620
Copy link

ajones620 commented Sep 26, 2020

Summary

As an Ambassador going through the sign-up workflow, I do not want to be blocked by entering my state in lowercase format so that I do not experience any friction in the sign-up process.

Requirements

  • When I am signing up to be an Ambassador, if I enter either or both characters for my state in lowercase format, I should not see an error
  • Currently the error message for using any lowercase characters is "Sorry, but state employment laws don't allow us to pay Voting Ambassadors in your state."

Current page/error message for reference:
Screen Shot 2020-09-25 at 6 49 45 PM

@joshmaker
Copy link

I wonder if this change to HelloVoter would fix this issue:

diff --git a/server/app/services/ambassadors.js b/server/app/services/ambassadors.js
index 36b63662..f77aec95 100644
--- a/server/app/services/ambassadors.js
+++ b/server/app/services/ambassadors.js
@@ -59,8 +59,8 @@ async function signup(json) {
     throw new ValidationError("Our system doesn’t recognize that phone number. Please try again.");
   }

-  let allowed_states = ov_config.allowed_states.split(',');
-  if (allowed_states.indexOf(json.address.state) === -1) {
+  let allowed_states = ov_config.allowed_states.toUpperCase().split(',');
+  if (allowed_states.indexOf(json.address.state.toUpperCase()) === -1) {
     throw new ValidationError("Sorry, but state employment laws don't allow us to pay Voting Ambassadors in your state.")
   }

@shauminn-colab shauminn-colab moved this from To Do to In Progress in BlockPower Voting Ambassador Frontend Sep 26, 2020
joshmaker added a commit to joshmaker/HelloVoter that referenced this issue Sep 26, 2020
indexOf() is case sensitive, so this code converts both the list of allowed states and the state in the JSON request to uppercase before doing the search to ensure a case insensitive match. It then saves the state into Neo4J as uppercase for consistency.

See:
colab-coop/hello-voter#121
colab-coop#46
@joshmaker
Copy link

I think this ticket should be resolved now that colab-coop/HelloVoter#48 has been merged. Basically, I convert everything to uppercase on the backend that way the API can receive lower, upper, or mixed case state abbreviations and it won't matter.

@shauminn-colab
Copy link
Contributor

That's so awesome @joshmaker - thank you! ill test it out on stage2 👍

@shauminn-colab shauminn-colab moved this from QA to Ready for Deployment in BlockPower Voting Ambassador Frontend Sep 27, 2020
@shauminn-colab shauminn-colab moved this from Ready for Deployment to Deployed in BlockPower Voting Ambassador Frontend Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants