From c01c62f149e210118e70838fa26a249b9ac1361d Mon Sep 17 00:00:00 2001 From: floatingghost Date: Tue, 22 Nov 2022 14:44:44 +0000 Subject: [PATCH] Redirect users to "awaiting approval" message on register (#231) Ref #81 - this implements a "your request has been sent" message ![image](/attachments/61dc3f5e-2706-46f9-a1ca-4efe3f526ff3) Co-authored-by: FloatingGhost Reviewed-on: https://akkoma.dev/AkkomaGang/pleroma-fe/pulls/231 --- package.json | 6 +- src/boot/routes.js | 4 + .../awaiting_email_confirmation.js | 4 + .../awaiting_email_confirmation.vue | 12 + src/components/registration/registration.js | 12 +- src/components/registration/registration.vue | 1 + .../registration_request_sent.js | 4 + .../registration_request_sent.vue | 12 + src/components/rich_content/rich_content.jsx | 2 - src/i18n/en.json | 4 + src/modules/users.js | 14 +- yarn.lock | 1564 +---------------- 12 files changed, 133 insertions(+), 1506 deletions(-) create mode 100644 src/components/awaiting_email_confirmation/awaiting_email_confirmation.js create mode 100644 src/components/awaiting_email_confirmation/awaiting_email_confirmation.vue create mode 100644 src/components/registration_request_sent/registration_request_sent.js create mode 100644 src/components/registration_request_sent/registration_request_sent.vue diff --git a/package.json b/package.json index bf803011..19a7e186 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "@fortawesome/free-solid-svg-icons": "^6.2.0", "@fortawesome/vue-fontawesome": "3.0.1", "@kazvmoe-infra/pinch-zoom-element": "1.2.0", - "@vuelidate/core": "2.0.0-alpha.42", - "@vuelidate/validators": "2.0.0-alpha.30", + "@vuelidate/core": "^2.0.0", + "@vuelidate/validators": "^2.0.0", "body-scroll-lock": "2.7.1", "chromatism": "3.0.0", "click-outside-vue3": "4.0.1", @@ -33,8 +33,6 @@ "escape-html": "1.0.3", "js-cookie": "^3.0.1", "localforage": "1.10.0", - "marked": "^4.2.2", - "marked-mfm": "^0.5.0", "parse-link-header": "^2.0.0", "phoenix": "1.6.2", "punycode.js": "2.1.0", diff --git a/src/boot/routes.js b/src/boot/routes.js index d762f057..93a94a9b 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -22,6 +22,8 @@ import Lists from 'components/lists/lists.vue' import ListTimeline from 'components/list_timeline/list_timeline.vue' import ListEdit from 'components/list_edit/list_edit.vue' import AnnouncementsPage from 'components/announcements_page/announcements_page.vue' +import RegistrationRequestSent from 'components/registration_request_sent/registration_request_sent.vue' +import AwaitingEmailConfirmation from 'components/awaiting_email_confirmation/awaiting_email_confirmation.vue' export default (store) => { const validateAuthenticatedRoute = (to, from, next) => { @@ -62,6 +64,8 @@ export default (store) => { { name: 'interactions', path: '/users/:username/interactions', component: Interactions, beforeEnter: validateAuthenticatedRoute }, { name: 'dms', path: '/users/:username/dms', component: DMs, beforeEnter: validateAuthenticatedRoute }, { name: 'registration', path: '/registration', component: Registration }, + { name: 'registration-request-sent', path: '/registration-request-sent', component: RegistrationRequestSent }, + { name: 'awaiting-email-confirmation', path: '/awaiting-email-confirmation', component: AwaitingEmailConfirmation }, { name: 'password-reset', path: '/password-reset', component: PasswordReset, props: true }, { name: 'registration-token', path: '/registration/:token', component: Registration }, { name: 'friend-requests', path: '/friend-requests', component: FollowRequests, beforeEnter: validateAuthenticatedRoute }, diff --git a/src/components/awaiting_email_confirmation/awaiting_email_confirmation.js b/src/components/awaiting_email_confirmation/awaiting_email_confirmation.js new file mode 100644 index 00000000..3809de4a --- /dev/null +++ b/src/components/awaiting_email_confirmation/awaiting_email_confirmation.js @@ -0,0 +1,4 @@ +export default { + computed: { + } +} diff --git a/src/components/awaiting_email_confirmation/awaiting_email_confirmation.vue b/src/components/awaiting_email_confirmation/awaiting_email_confirmation.vue new file mode 100644 index 00000000..559457e6 --- /dev/null +++ b/src/components/awaiting_email_confirmation/awaiting_email_confirmation.vue @@ -0,0 +1,12 @@ + + + diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js index 6eb316d0..9778a2f3 100644 --- a/src/components/registration/registration.js +++ b/src/components/registration/registration.js @@ -79,8 +79,16 @@ const registration = { if (!this.v$.$invalid) { try { - await this.signUp(this.user) - this.$router.push({ name: 'friends' }) + const data = await this.signUp(this.user) + if (data.me) { + this.$router.push({ name: 'friends' }) + } else if (data.identifier === 'awaiting_approval') { + this.$router.push({ name: 'registration-request-sent' }) + } else if (data.identifier === 'missing_confirmed_email') { + this.$router.push({ name: 'awaiting-email-confirmation' }) + } else { + console.warn('Unknown response from sign up', data) + } } catch (error) { console.warn('Registration failed: ', error) this.setCaptcha() diff --git a/src/components/registration/registration.vue b/src/components/registration/registration.vue index cc655c0b..9a88d68d 100644 --- a/src/components/registration/registration.vue +++ b/src/components/registration/registration.vue @@ -177,6 +177,7 @@