From ba73f0ea3a0bcfc21dc8f0111eac4f0bce7101ca Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 25 May 2023 22:26:39 +0200 Subject: [PATCH] [Glitch] Add polling and automatic redirection to `/start` on email confirmation Port e60414792d86a99c0f401f3c1bab92ee37835d39 to glitch-soc --- app/controllers/auth/setup_controller.rb | 2 +- app/javascript/core/theme.yml | 1 + app/javascript/flavours/glitch/packs/sign_up.js | 15 +++++++++++++++ app/javascript/flavours/glitch/theme.yml | 1 + app/javascript/flavours/vanilla/theme.yml | 1 + app/views/auth/setup/show.html.haml | 2 -- 6 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 app/javascript/flavours/glitch/packs/sign_up.js diff --git a/app/controllers/auth/setup_controller.rb b/app/controllers/auth/setup_controller.rb index 3ee35d141c..8edca4d01b 100644 --- a/app/controllers/auth/setup_controller.rb +++ b/app/controllers/auth/setup_controller.rb @@ -45,6 +45,6 @@ class Auth::SetupController < ApplicationController end def set_pack - use_pack 'auth' + use_pack 'sign_up' end end diff --git a/app/javascript/core/theme.yml b/app/javascript/core/theme.yml index b9144e43aa..30676dcf58 100644 --- a/app/javascript/core/theme.yml +++ b/app/javascript/core/theme.yml @@ -16,4 +16,5 @@ pack: modal: public.js public: public.js settings: settings.js + sign_up: share: diff --git a/app/javascript/flavours/glitch/packs/sign_up.js b/app/javascript/flavours/glitch/packs/sign_up.js new file mode 100644 index 0000000000..ed03f1cf4b --- /dev/null +++ b/app/javascript/flavours/glitch/packs/sign_up.js @@ -0,0 +1,15 @@ +import 'packs/public-path'; +import ready from 'flavours/glitch/ready'; +import axios from 'axios'; + +ready(() => { + setInterval(() => { + axios.get('/api/v1/emails/check_confirmation').then((response) => { + if (response.data) { + window.location = '/start'; + } + }).catch(error => { + console.error(error); + }); + }, 5000); +}); diff --git a/app/javascript/flavours/glitch/theme.yml b/app/javascript/flavours/glitch/theme.yml index 672dd54406..0877e4d400 100644 --- a/app/javascript/flavours/glitch/theme.yml +++ b/app/javascript/flavours/glitch/theme.yml @@ -20,6 +20,7 @@ pack: modal: public: packs/public.jsx settings: packs/settings.js + sign_up: packs/sign_up.js share: packs/share.jsx # (OPTIONAL) The directory which contains localization files for diff --git a/app/javascript/flavours/vanilla/theme.yml b/app/javascript/flavours/vanilla/theme.yml index ccab925aa9..470ded5302 100644 --- a/app/javascript/flavours/vanilla/theme.yml +++ b/app/javascript/flavours/vanilla/theme.yml @@ -20,6 +20,7 @@ pack: modal: public: public.jsx settings: public.jsx + sign_up: sign_up.js share: share.jsx # (OPTIONAL) The directory which contains localization files for diff --git a/app/views/auth/setup/show.html.haml b/app/views/auth/setup/show.html.haml index 64deca3345..913b0c9132 100644 --- a/app/views/auth/setup/show.html.haml +++ b/app/views/auth/setup/show.html.haml @@ -1,8 +1,6 @@ - content_for :page_title do = t('auth.setup.title') -= javascript_pack_tag 'sign_up', crossorigin: 'anonymous' - = simple_form_for(@user, url: auth_setup_path) do |f| = render 'auth/shared/progress', stage: 'confirm'