diff --git a/www/js/setup1.js b/www/js/setup1.js index cdaff0a..c160b1b 100644 --- a/www/js/setup1.js +++ b/www/js/setup1.js @@ -26,7 +26,7 @@ function checkAndSave(username, password) { localStorage.setItem("accttype", "giver"); } else if (profile.profile.type == 2) { localStorage.setItem("accttype", "receiver"); - } else if (profile.profile.type == 3){ + } else if (profile.profile.type == 3) { app.preloader.hide(); app.dialog.alert("You need to download the merchant app instead. Visit ntsm.co/contact if you need help.", "Error"); return; @@ -61,17 +61,47 @@ function createAccount() { var username = $("#username").val(); var password = $("#password").val(); - app.preloader.show(); + if (username.length < 1) { + app.dialog.alert("Enter a username.", "Error"); + return; + } + if (password.length < SETTINGS["min_password_length"]) { + app.dialog.alert("Password must be at least " + SETTINGS["min_password_length"] + " characters long.", "Error"); + return; + } - callAPI("signup", { - username: username, - password: password, - accttype: type - }, function (data) { - app.preloader.hide(); - checkAndSave(username, password, type); - }, function (msg) { - app.preloader.hide(); - app.dialog.alert(msg, "Error"); - }); + app.dialog.create({ + text: "I agree to the terms of service and privacy policy.", + buttons: [ + { + text: "No", + onClick: function () { + restartApplication(); + } + }, + { + text: "Yes", + onClick: function () { + app.preloader.show(); + callAPI("signup", { + username: username, + password: password, + accttype: type + }, function (data) { + app.preloader.hide(); + checkAndSave(username, password, type); + }, function (msg) { + app.preloader.hide(); + app.dialog.alert(msg, "Error"); + }); + } + }, + { + text: "Show", + onClick: function () { + openBrowser(SETTINGS["terms_of_service_url"]); + } + }, + ] + }).open(); } \ No newline at end of file diff --git a/www/routes.js b/www/routes.js index fb9b87e..0ad1393 100644 --- a/www/routes.js +++ b/www/routes.js @@ -107,7 +107,7 @@ var routes = [ setting: "privacy", title: "Privacy Policy", text: "", - onclick: "openBrowser('https://netsyms.com/legal?pk_campaign=HelpingHelenaApp')" + onclick: "openBrowser('" + SETTINGS["terms_of_service_url"] + "')" }] } }); diff --git a/www/settings.template.js b/www/settings.template.js index fdc2323..6af1516 100644 --- a/www/settings.template.js +++ b/www/settings.template.js @@ -9,5 +9,7 @@ */ var SETTINGS = { server: "http://localhost/helpinghelena/api", - webapp_url: "https://app.helpinghelena.org/" + webapp_url: "https://app.helpinghelena.org/", + terms_of_service_url: "https://netsyms.com/legal?pk_campaign=HelpingHelenaApp", + min_password_length: 8 }; \ No newline at end of file