From 0aa35e3dde5005ab080220b42beb5e96b4604bf5 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Thu, 11 May 2023 15:15:18 +0000 Subject: [PATCH] CLASSROOMIO-T-42: Limit subdomain names available to organizations Co-authored-by: Rotimi Best Merge-request: CLASSROOMIO-MR-9 Merged-by: Digdippa Team --- .../components/Editor/DescriptionForm.svelte | 4 ++- .../components/Editor/GoalsForm.svelte | 4 ++- .../components/Editor/InstructorForm.svelte | 5 +++- .../components/Editor/PricingForm.svelte | 5 +++- .../components/Editor/RequirementForm.svelte | 4 ++- .../components/PricingSection.svelte | 10 ++----- .../Courses/components/Card/Loader.svelte | 2 +- .../Courses/components/Card/index.svelte | 2 +- src/components/ErrorMessage/index.svelte | 2 +- src/components/Form/TextField.svelte | 4 +-- src/components/Navigation/app.svelte | 4 ++- src/components/Org/Settings/Domains.svelte | 20 +++++++++++-- .../Org/Settings/OrgSettings.svelte | 10 +++---- src/components/Org/Settings/Profile.svelte | 6 ++-- .../Org/Settings/TeamMembers.svelte | 4 +-- src/routes/_layout.svelte | 30 +++++++++++++++---- src/routes/forgot.svelte | 2 +- src/routes/login.svelte | 2 +- src/routes/onboarding.svelte | 12 ++++++-- src/routes/reset.svelte | 2 +- src/routes/signup.svelte | 2 +- src/server.js | 2 ++ src/utils/constants/app.js | 24 +++++++++++++++ src/utils/functions/app.js | 2 +- 24 files changed, 121 insertions(+), 43 deletions(-) create mode 100644 src/utils/constants/app.js diff --git a/src/components/CourseLandingPage/components/Editor/DescriptionForm.svelte b/src/components/CourseLandingPage/components/Editor/DescriptionForm.svelte index 83c03cac..c33077be 100644 --- a/src/components/CourseLandingPage/components/Editor/DescriptionForm.svelte +++ b/src/components/CourseLandingPage/components/Editor/DescriptionForm.svelte @@ -1,5 +1,7 @@
diff --git a/src/components/Courses/components/Card/index.svelte b/src/components/Courses/components/Card/index.svelte index f8391850..edb7ed83 100644 --- a/src/components/Courses/components/Card/index.svelte +++ b/src/components/Courses/components/Card/index.svelte @@ -44,7 +44,7 @@
-

{message}

+

{message}

diff --git a/src/components/Form/TextField.svelte b/src/components/Form/TextField.svelte index 6c7c8b12..ad64c2d2 100644 --- a/src/components/Form/TextField.svelte +++ b/src/components/Form/TextField.svelte @@ -65,7 +65,7 @@ {/if} {/if} {#if errorMessage} -

{errorMessage}

+

{errorMessage}

{:else if helperMessage}

{helperMessage} diff --git a/src/components/Navigation/app.svelte b/src/components/Navigation/app.svelte index 1de5e861..4672d26c 100644 --- a/src/components/Navigation/app.svelte +++ b/src/components/Navigation/app.svelte @@ -1,4 +1,5 @@ - - Add + + Add

Add your team mates or collaborators to your organization. Start working @@ -85,7 +99,7 @@ - + Custom domain diff --git a/src/components/Org/Settings/OrgSettings.svelte b/src/components/Org/Settings/OrgSettings.svelte index 4dbc55a8..7d17e5bd 100644 --- a/src/components/Org/Settings/OrgSettings.svelte +++ b/src/components/Org/Settings/OrgSettings.svelte @@ -78,8 +78,8 @@ } - - + + Organization Profile @@ -104,13 +104,13 @@ /> - - + Custom Domain @@ -127,7 +127,7 @@ /> - + Team

Set up your website

diff --git a/src/components/Org/Settings/Profile.svelte b/src/components/Org/Settings/Profile.svelte index 42e895d7..81fb0767 100644 --- a/src/components/Org/Settings/Profile.svelte +++ b/src/components/Org/Settings/Profile.svelte @@ -81,8 +81,8 @@ } - - + + Profile Picture @@ -94,7 +94,7 @@ /> - + Personal Information diff --git a/src/components/Org/Settings/TeamMembers.svelte b/src/components/Org/Settings/TeamMembers.svelte index d02fcbf8..b304c986 100644 --- a/src/components/Org/Settings/TeamMembers.svelte +++ b/src/components/Org/Settings/TeamMembers.svelte @@ -128,7 +128,7 @@ - + Add @@ -162,7 +162,7 @@ - + Members diff --git a/src/routes/_layout.svelte b/src/routes/_layout.svelte index 97f6ace9..1f3364e2 100644 --- a/src/routes/_layout.svelte +++ b/src/routes/_layout.svelte @@ -1,6 +1,6 @@ @@ -8,8 +8,9 @@ import { onMount } from 'svelte'; import { derived } from 'svelte/store'; import { stores, goto } from '@sapper/app'; - import _ from 'lodash'; + import isEmpty from 'lodash/isEmpty'; import * as Sentry from '@sentry/browser'; + import { Theme } from 'carbon-components-svelte'; import { Moon } from 'svelte-loading-spinners'; import Tailwindcss from '../components/Tailwindcss.svelte'; import LandingNavigation from '../components/Navigation/index.svelte'; @@ -30,13 +31,17 @@ import { toggleBodyByTheme } from '../utils/functions/app'; import { appStore } from '../utils/store/app'; + // import 'carbon-components-svelte/css/all.css'; + export let segment; export let config; + export let host; let { page, preloading } = stores(); let supabase = getSupabase(config); let path = $page.path.replace('/', ''); + let theme = 'white'; const delayedPreloading = derived(preloading, (currentPreloading, set) => { setTimeout(() => set(currentPreloading), 250); @@ -98,7 +103,7 @@ const orgRes = await getOrganizations($profile.id); // If user coming to login page, then - if (_.isEmpty(orgRes.orgs)) { + if (isEmpty(orgRes.orgs)) { goto(ROUTE.ONBOARDING); } else if ( ['login', 'signup', 'onboarding'].includes(path) || @@ -123,7 +128,7 @@ } onMount(() => { - console.log('Welcome to ClassroomIO, we are grateful you chose us.'); + console.log('Welcome to ClassroomIO, we are grateful you chose us.', host); // Disable GA on localhost if (config && !config.isProd) { console.log('disable GA'); @@ -179,14 +184,21 @@ // } $: path = $page.path.replace('/', ''); + $: theme = $appStore.isDark ? 'g100' : 'white'; + + + @@ -262,4 +274,12 @@ :global(.dark svg.dark path) { fill: #fff; } + + :global(.border-c) { + border: 1px solid var(--border-color); + } + + :global(.border-bottom-c) { + border-bottom: 1px solid var(--border-color); + } diff --git a/src/routes/forgot.svelte b/src/routes/forgot.svelte index af23459b..4ce7f33b 100644 --- a/src/routes/forgot.svelte +++ b/src/routes/forgot.svelte @@ -98,7 +98,7 @@ errorMessage={errors.email} /> {#if submitError} -

{submitError}

+

{submitError}

{/if}
diff --git a/src/routes/login.svelte b/src/routes/login.svelte index 1995cec3..8170e525 100644 --- a/src/routes/login.svelte +++ b/src/routes/login.svelte @@ -81,7 +81,7 @@ errorMessage={errors.password} /> {#if submitError} -

{submitError}

+

{submitError}

{/if}
Forgot password? diff --git a/src/routes/onboarding.svelte b/src/routes/onboarding.svelte index 2621e8a0..48afc5c4 100644 --- a/src/routes/onboarding.svelte +++ b/src/routes/onboarding.svelte @@ -15,6 +15,7 @@ import { orgs, currentOrg } from '../utils/store/org'; import { onboardingValidation } from '../utils/functions/validator'; import { supabase } from '../utils/functions/supabase'; + import { blockedSubdomain } from '../utils/constants/app'; interface OnboardingField { fullname?: string; @@ -110,6 +111,13 @@ } if (step === 1) { + // Validate if domain is among our seculeded subdomains + if (blockedSubdomain.includes(fields.siteName || '')) { + errors.siteName = 'Sitename already exists.'; + loading = false; + return; + } + const { data: org, error } = await supabase.from('organization').insert({ name: fields.orgName, siteName: fields.siteName, @@ -276,7 +284,7 @@ {/each} {#if errors.goal} -

+

{errors.goal}

{/if} @@ -308,7 +316,7 @@ {/each} {#if errors.source} -

+

{errors.source}

{/if} diff --git a/src/routes/reset.svelte b/src/routes/reset.svelte index 63b36c49..ee9059a4 100644 --- a/src/routes/reset.svelte +++ b/src/routes/reset.svelte @@ -97,7 +97,7 @@ isRequired /> {#if submitError} -

{submitError}

+

{submitError}

{/if}
diff --git a/src/routes/signup.svelte b/src/routes/signup.svelte index 569a09b5..45d4c645 100644 --- a/src/routes/signup.svelte +++ b/src/routes/signup.svelte @@ -124,7 +124,7 @@ isRequired /> {#if submitError} -

{submitError}

+

{submitError}

{/if}
diff --git a/src/server.js b/src/server.js index 6a1af243..d798530e 100644 --- a/src/server.js +++ b/src/server.js @@ -33,9 +33,11 @@ express() // You can also use Express session: async (req) => { const { user } = await supabase.auth.api.getUserByCookie(req); console.log('cookie calling'); + // console.log('req', req.headers.host); return { user: JSON.stringify(user), config, + host: req.headers.host, }; }, }) diff --git a/src/utils/constants/app.js b/src/utils/constants/app.js new file mode 100644 index 00000000..4684bf0c --- /dev/null +++ b/src/utils/constants/app.js @@ -0,0 +1,24 @@ +export const blockedSubdomain = [ + 'app', + 'apps', + 'support', + 'help', + 'teachers', + 'church', + 'tech', + 'build', + 'community', + 'conference', + 'campaign', + 'blog', + 'forum', + 'mobile', + 'dev', + 'stage', + 'prod', + 'group', + 'groups', + 'academy', + 'schools', + 'training', +]; diff --git a/src/utils/functions/app.js b/src/utils/functions/app.js index 00d58e9c..622cb446 100644 --- a/src/utils/functions/app.js +++ b/src/utils/functions/app.js @@ -2,6 +2,6 @@ export function toggleBodyByTheme(isDark) { if (isDark) { document.body.className = document.body.className.concat(' ', 'dark'); } else { - document.body.className = document.body.className.replace('dark', ''); + document.body.className = document.body.className.replace(' dark', ''); } }