From 8fc4879410f073ad6d813f2f10406ab1a45ed272 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 19 Oct 2021 17:31:18 -0600 Subject: [PATCH] Separate account number from phone number --- www/assets/js/account.js | 31 +++++++++++++++++-------------- www/assets/js/dropandsend.js | 6 +++--- www/assets/js/main.js | 8 +++++++- www/assets/js/settings.js | 2 +- www/pages/account.html | 9 +++++++++ 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/www/assets/js/account.js b/www/assets/js/account.js index a3f630c..c780697 100644 --- a/www/assets/js/account.js +++ b/www/assets/js/account.js @@ -6,9 +6,9 @@ function checkAccountStatus(callback) { - if (inStorage("phonenumber")) { + if (inStorage("accountnumber")) { apirequest(SETTINGS.apis.authorstartverify, { - phone: getStorage("phonenumber"), + accountnumber: getStorage("accountnumber"), accountkey: (inStorage("accountkey") ? getStorage("accountkey") : "") }, function (resp) { if (resp.status == "OK") { @@ -27,7 +27,7 @@ function checkAccountStatus(callback) { router.back(); // Server is saying something's wrong, let's clear the account number in case // the user wants to try a different one. - removeFromStorage("phonenumber"); + removeFromStorage("accountnumber"); app.dialog.alert(resp.msg, "Error"); } }, function (err) { @@ -40,12 +40,12 @@ function checkAccountStatus(callback) { } function checkIfAccountGoodWithPaymentMethod(successcb, errorcb) { - if (!inStorage("phonenumber") || !inStorage("accountkey")) { + if (!inStorage("accountnumber") || !inStorage("accountkey")) { successcb(false); return; } apirequest(SETTINGS.apis.getaccountinfo, { - phone: getStorage("phonenumber"), + accountnumber: getStorage("accountnumber"), accountkey: getStorage("accountkey") }, function (success) { if (success.status == "OK") { @@ -79,7 +79,7 @@ function verifyCode(code) { app.dialog.preloader("Verifying..."); apirequest(SETTINGS.apis.verifyauthcode, { code: code, - phone: getStorage("phonenumber") + accountnumber: getStorage("accountnumber") }, function (resp) { app.dialog.close(); if (resp.status == "OK") { @@ -98,13 +98,13 @@ function verifyCode(code) { function displayAccountInfo() { $("#loyaltyBalanceBox").addClass("display-none"); $("#loyaltyErrorMessage").html(""); - if (inStorage("accountkey") && inStorage("phonenumber")) { + if (inStorage("accountkey") && inStorage("accountnumber")) { } else { $("#loyaltyErrorMessage").text("Error: No account connected."); return; } apirequest(SETTINGS.apis.getaccountinfo, { - phone: getStorage("phonenumber"), + accountnumber: getStorage("accountnumber"), accountkey: getStorage("accountkey") }, function (success) { $("#hasaccountbox").css("display", ""); @@ -112,7 +112,7 @@ function displayAccountInfo() { if (success.status == "OK") { $("#loyaltyCreditBalanceHeading").text(success.credits + " points"); $("#loyaltyBalanceBox").removeClass("display-none") - $("#accountnumberspan").text(success.phone); + $("#accountnumberspan").text(success.accountnumber); if (success.payments_setup === false) { $("#addPaymentMethodBox").css("display", ""); @@ -121,6 +121,7 @@ function displayAccountInfo() { } $("#accountupdateform input#name").val(success.name); + $("#accountupdateform input#phone").val(success.phone); $("#accountupdateform input#email").val(success.email); $("#accountupdateform input#streetaddress").val(success.streetaddress); $("#accountupdateform input#zipcode").val(success.zipcode); @@ -168,7 +169,7 @@ $("body").on("click", "#setupAccountBtn", function () { app.dialog.alert(resp.msg, "Error"); return; } else { - setStorage("phonenumber", resp.phone); + setStorage("accountnumber", resp.accountnumber); router.refreshPage(); } }, function (error) { @@ -196,9 +197,10 @@ $("body").on("click", "#updateAccountBtn", function () { } app.dialog.preloader("Updating Account..."); apirequest(SETTINGS.apis.accountregister, { - phone: getStorage("phonenumber"), + accountnumber: getStorage("accountnumber"), accountkey: getStorage("accountkey"), name: $("#accountupdateform input#name").val(), + phone: $("#accountupdateform input#phone").val(), email: $("#accountupdateform input#email").val(), address: $("#accountupdateform input#streetaddress").val(), zipcode: $("#accountupdateform input#zipcode").val() @@ -210,7 +212,7 @@ $("body").on("click", "#updateAccountBtn", function () { return; } else { app.popup.close("#accountUpdatePopup", true); - setStorage("phonenumber", resp.phone); + setStorage("accountnumber", resp.accountnumber); router.refreshPage(); app.dialog.alert("Account details updated.", "Account Updated"); } @@ -227,7 +229,7 @@ $("body").on("click", "#connectExistingAccountBtn", function () { app.dialog.alert("Please enter a full 10-digit phone number.", "Oops!"); return; } - setStorage("phonenumber", phone); + setStorage("accountnumber", accountnumber); router.refreshPage(); }, function (cancel) { // shrug @@ -236,6 +238,7 @@ $("body").on("click", "#connectExistingAccountBtn", function () { $("body").on("popup:open", "#accountUpdatePopup", function () { app.input.checkEmptyState("#accountupdateform input#name"); + app.input.checkEmptyState("#accountupdateform input#phone"); app.input.checkEmptyState("#accountupdateform input#email"); app.input.checkEmptyState("#accountupdateform input#streetaddress"); app.input.checkEmptyState("#accountupdateform input#zipcode"); @@ -269,7 +272,7 @@ function openCheckoutWindowToSaveCard(onaccountpage) { onaccountpage = true; } openBrowser(SETTINGS.apis.redirecttopaymentsetup - + "?phone=" + getStorage("phonenumber") + + "?accountnumber=" + getStorage("accountnumber") + "&accountkey=" + getStorage("accountkey"), "location=yes,hidenavigationbuttons=yes,hideurlbar=yes,zoom=no,hardwareback=no,fullscreen=no,presentationstyle=pagesheet,toolbarposition=top,lefttoright=yes,toolbarcolor=#D0F2FC", function () { diff --git a/www/assets/js/dropandsend.js b/www/assets/js/dropandsend.js index 6a0ba41..1af5236 100644 --- a/www/assets/js/dropandsend.js +++ b/www/assets/js/dropandsend.js @@ -35,7 +35,7 @@ function captureAndSendPickupCode() { function sendPickupCode(code) { app.dialog.preloader("Loading..."); apirequest(SETTINGS.apis.dropandsendpickup, { - phone: getStorage("phonenumber"), + accountnumber: getStorage("accountnumber"), accountkey: getStorage("accountkey"), locationnumber: code }, function (resp) { @@ -139,7 +139,7 @@ $("body").on("popup:open", "#dasLocationMapPopup", function () { $("body").on("popup:open", "#dasHowItWorksPopup", function () { // Put user's account number in the instructions - if (inStorage("phonenumber") && inStorage("accountkey")) { - $("#dasHowItWorksAccountNumber").text(" (yours is " + getStorage("phonenumber") + ")"); + if (inStorage("accountnumber") && inStorage("accountkey")) { + $("#dasHowItWorksAccountNumber").text(" (yours is " + getStorage("accountnumber") + ")"); } }); \ No newline at end of file diff --git a/www/assets/js/main.js b/www/assets/js/main.js index a815b08..16f69d7 100644 --- a/www/assets/js/main.js +++ b/www/assets/js/main.js @@ -165,7 +165,13 @@ function setAnimations(enabled) { applyColorTheme(); setAnimations(); -var setup = (inStorage("phonenumber") && inStorage("accountkey")) || inStorage("setupskipped"); +// Migrate from old to new account number storage key +if (inStorage("phonenumber") && !inStorage("accountnumber")) { + setStorage("accountnumber", getStorage("phonenumber")); + removeFromStorage("phonenumber"); +} + +var setup = (inStorage("accountnumber") && inStorage("accountkey")) || inStorage("setupskipped"); app.init(); diff --git a/www/assets/js/settings.js b/www/assets/js/settings.js index 8026630..c23e8cb 100644 --- a/www/assets/js/settings.js +++ b/www/assets/js/settings.js @@ -35,7 +35,7 @@ $('.item-content[data-setting=hideaccountnag] .toggle input').on("change", funct function resetAccountPrompt() { app.dialog.confirm("Are you sure you want to log out?", function () { - removeFromStorage("phonenumber"); + removeFromStorage("accountnumber"); removeFromStorage("accountkey"); restartApplication(); }); diff --git a/www/pages/account.html b/www/pages/account.html index 041c9c5..05e6f57 100644 --- a/www/pages/account.html +++ b/www/pages/account.html @@ -143,6 +143,15 @@ +
  • +
    +
    Phone Number
    +
    + + +
    +
    +
  • Email