From 15793496e8d56769c792cf39673c6e6dea3ec4d9 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 28 Jun 2018 21:15:57 +0200 Subject: Preparing for complete rewrite.. --- .../userfrosting/js/pages/account-settings.js | 29 ------- .../userfrosting/js/pages/forgot-password.js | 18 ----- .../assets/userfrosting/js/pages/register.js | 93 ---------------------- .../userfrosting/js/pages/resend-verification.js | 18 ----- .../userfrosting/js/pages/set-or-reset-password.js | 18 ----- .../assets/userfrosting/js/pages/sign-in.js | 73 ----------------- 6 files changed, 249 deletions(-) delete mode 100644 main/app/sprinkles/account/assets/userfrosting/js/pages/account-settings.js delete mode 100644 main/app/sprinkles/account/assets/userfrosting/js/pages/forgot-password.js delete mode 100644 main/app/sprinkles/account/assets/userfrosting/js/pages/register.js delete mode 100644 main/app/sprinkles/account/assets/userfrosting/js/pages/resend-verification.js delete mode 100644 main/app/sprinkles/account/assets/userfrosting/js/pages/set-or-reset-password.js delete mode 100644 main/app/sprinkles/account/assets/userfrosting/js/pages/sign-in.js (limited to 'main/app/sprinkles/account/assets') diff --git a/main/app/sprinkles/account/assets/userfrosting/js/pages/account-settings.js b/main/app/sprinkles/account/assets/userfrosting/js/pages/account-settings.js deleted file mode 100644 index f1e9845..0000000 --- a/main/app/sprinkles/account/assets/userfrosting/js/pages/account-settings.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Page-specific Javascript file. Should generally be included as a separate asset bundle in your page template. - * example: {{ assets.js('js/pages/sign-in-or-register') | raw }} - * - * This script depends on validation rules specified in pages/partials/page.js.twig. - * - * Target page: account/settings - */ -$(document).ready(function () { - - // Apply select2 to locale field - $('.js-select2').select2(); - - $("#account-settings").ufForm({ - validators: page.validators.account_settings, - msgTarget: $("#alerts-page") - }).on("submitSuccess.ufForm", function () { - // Reload the page on success - window.location.reload(); - }); - - $("#profile-settings").ufForm({ - validators: page.validators.profile_settings, - msgTarget: $("#alerts-page") - }).on("submitSuccess.ufForm", function () { - // Reload the page on success - window.location.reload(); - }); -}); diff --git a/main/app/sprinkles/account/assets/userfrosting/js/pages/forgot-password.js b/main/app/sprinkles/account/assets/userfrosting/js/pages/forgot-password.js deleted file mode 100644 index 6eaa401..0000000 --- a/main/app/sprinkles/account/assets/userfrosting/js/pages/forgot-password.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Page-specific Javascript file. Should generally be included as a separate asset bundle in your page template. - * example: {{ assets.js('js/pages/sign-in-or-register') | raw }} - * - * This script depends on validation rules specified in pages/partials/page.js.twig. - * - * Target page: account/forgot-password - */ -$(document).ready(function () { - - $("#request-password-reset").ufForm({ - validators: page.validators.forgot_password, - msgTarget: $("#alerts-page") - }).on("submitSuccess.ufForm", function () { - // Forward to login page on success - window.location.replace(site.uri.public + "/account/sign-in"); - }); -}); diff --git a/main/app/sprinkles/account/assets/userfrosting/js/pages/register.js b/main/app/sprinkles/account/assets/userfrosting/js/pages/register.js deleted file mode 100644 index 4539d9b..0000000 --- a/main/app/sprinkles/account/assets/userfrosting/js/pages/register.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Page-specific Javascript file. Should generally be included as a separate asset bundle in your page template. - * example: {{ assets.js('js/pages/sign-in-or-register') | raw }} - * - * This script depends on validation rules specified in pages/partials/page.js.twig. - * - * Target page: account/register - */ -$(document).ready(function () { - // TOS modal - $(this).find('.js-show-tos').click(function () { - $("body").ufModal({ - sourceUrl: site.uri.public + "/modals/account/tos", - msgTarget: $("#alerts-page") - }); - }); - - // Auto-generate username when name is filled in - var autoGenerate = true; - $("#register").find('input[name=first_name], input[name=last_name]').on('input change', function () { - if (!autoGenerate) { - return; - } - - var form = $("#register"); - - var firstName = form.find('input[name=first_name]').val().trim(); - var lastName = form.find('input[name=last_name]').val().trim(); - - if (!firstName && !lastName) { - return; - } - - var userName = getSlug(firstName + ' ' + lastName, { - separator: '.' - }); - // Set slug - form.find('input[name=user_name]').val(userName); - }); - - // Autovalidate username field on a delay - var timer; - $("#register").find('input[name=first_name], input[name=last_name], input[name=user_name]').on('input change', function () { - clearTimeout(timer); // Clear the timer so we don't end up with dupes. - timer = setTimeout(function () { // assign timer a new timeout - $("#register").find('input[name=user_name]').valid(); - }, 50); - }); - - // Enable/disable username suggestions in registration page - $("#register").find('#form-register-username-suggest').on('click', function (e) { - e.preventDefault(); - var form = $("#register"); - $.getJSON(site.uri.public + '/account/suggest-username') - .done(function (data) { - // Set suggestion - form.find('input[name=user_name]').val(data.user_name); - }); - }); - - // Turn off autogenerate when someone enters stuff manually in user_name - $("#register").find('input[name=user_name]').on('input', function () { - autoGenerate = false; - }); - - // Add remote rule for checking usernames on the fly - var registrationValidators = $.extend( - true, // deep extend - page.validators.register, - { - rules: { - user_name: { - remote: { - url: site.uri.public + '/account/check-username', - dataType: 'text' - } - } - } - } - ); - - // Handles form submission - $("#register").ufForm({ - validators: registrationValidators, - msgTarget: $("#alerts-page"), - keyupDelay: 500 - }).on("submitSuccess.ufForm", function () { - window.location.reload(); - }).on("submitError.ufForm", function () { - // Reload captcha - $("#captcha").captcha(); - }); -}); diff --git a/main/app/sprinkles/account/assets/userfrosting/js/pages/resend-verification.js b/main/app/sprinkles/account/assets/userfrosting/js/pages/resend-verification.js deleted file mode 100644 index a6db823..0000000 --- a/main/app/sprinkles/account/assets/userfrosting/js/pages/resend-verification.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Page-specific Javascript file. Should generally be included as a separate asset bundle in your page template. - * example: {{ assets.js('js/pages/sign-in-or-register') | raw }} - * - * This script depends on validation rules specified in pages/partials/page.js.twig. - * - * Target page: account/resend-verification - */ -$(document).ready(function () { - - $("#request-verification-email").ufForm({ - validators: page.validators.resend_verification, - msgTarget: $("#alerts-page") - }).on("submitSuccess.ufForm", function () { - // Forward to login page on success - window.location.replace(site.uri.public + "/account/sign-in"); - }); -}); diff --git a/main/app/sprinkles/account/assets/userfrosting/js/pages/set-or-reset-password.js b/main/app/sprinkles/account/assets/userfrosting/js/pages/set-or-reset-password.js deleted file mode 100644 index f5e2227..0000000 --- a/main/app/sprinkles/account/assets/userfrosting/js/pages/set-or-reset-password.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Page-specific Javascript file. Should generally be included as a separate asset bundle in your page template. - * example: {{ assets.js('js/pages/sign-in-or-register') | raw }} - * - * This script depends on validation rules specified in pages/partials/page.js.twig. - * - * Target pages: account/set-password, account/reset-password - */ -$(document).ready(function () { - - $("#set-or-reset-password").ufForm({ - validators: page.validators.set_password, - msgTarget: $("#alerts-page") - }).on("submitSuccess.ufForm", function () { - // Forward to home page on success - window.location.replace(site.uri.public + "/account/sign-in"); - }); -}); diff --git a/main/app/sprinkles/account/assets/userfrosting/js/pages/sign-in.js b/main/app/sprinkles/account/assets/userfrosting/js/pages/sign-in.js deleted file mode 100644 index 7362d6d..0000000 --- a/main/app/sprinkles/account/assets/userfrosting/js/pages/sign-in.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Page-specific Javascript file. Should generally be included as a separate asset bundle in your page template. - * example: {{ assets.js('js/pages/sign-in-or-register') | raw }} - * - * This script depends on validation rules specified in pages/partials/page.js.twig. - * - * Target page: account/sign-in - */ -$(document).ready(function () { - /** - * If there is a redirect parameter in the query string, redirect to that page. - * Otherwise, if there is a UF-Redirect header, redirect to that page. - * Otherwise, redirect to the home page. - */ - function redirectOnLogin(jqXHR) { - var components = URI.parse(window.location.href); - var query = URI.parseQuery(components['query']); - - if (query && query['redirect']) { - // Strip leading slashes from redirect strings - var redirectString = site.uri.public + '/' + query['redirect'].replace(/^\/+/, ""); - // Strip excess trailing slashes for clean URLs. e.g. if redirect=%2F - redirectString = redirectString.replace(/\/+$/, "/"); - // Redirect - window.location.replace(redirectString); - } else if (jqXHR.getResponseHeader('UF-Redirect')) { - window.location.replace(jqXHR.getResponseHeader('UF-Redirect')); - } else { - window.location.replace(site.uri.public); - } - } - - $("#sign-in").ufForm({ - validators: page.validators.login, - msgTarget: $("#alerts-page") - }).on("submitSuccess.ufForm", function (event, data, textStatus, jqXHR) { - if (localStorage.getItem("PrivateKey") === null && localStorage.getItem("🔒") === null) { - // GENERATE KEYS - var openpgp = window.openpgp; - var options; - var randomString = Math.random().toString(36).substr(2, 11); // PRIVKEY ENCRYPTION KEY - openpgp.initWorker({path: '/assets-raw/core/assets/SiteAssets/js/openpgp.worker.js'}); - options = { - userIds: [{name: $("input[name=user_name]").val()}], - curve: "curve25519", - passphrase: randomString - }; - openpgp.generateKey(options).then(function (key) { - localStorage.setItem("PrivateKey", key.privateKeyArmored); - localStorage.setItem("🔒", randomString); - - console.log(key.publicKeyArmored); - console.log(key.privateKeyArmored); - // SAVE PUBLIC KEY TO DATABASE - var data = { - csrf_name: site.csrf.name, - csrf_value: site.csrf.value, - PublicKey: key.publicKeyArmored - }; - $.ajax({ - type: 'POST', - dataType: "json", - url: site.uri.public + '/api/users/u/' + $("input[name=user_name]").val() + '/publickey', - data: data, - async: false - }); - redirectOnLogin(jqXHR); - }); - } else { - redirectOnLogin(jqXHR); - } - }); -}); -- cgit v1.2.3