chore: restrict accounts

This commit is contained in:
Rotimi Best
2024-08-24 20:44:16 +01:00
parent 4ffee61cb0
commit a00bb133af
6 changed files with 67 additions and 2 deletions
@@ -0,0 +1,32 @@
<script>
import { goto } from '$app/navigation';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
import Locked from 'carbon-icons-svelte/lib/Locked.svelte';
function handleClick() {
return goto('https://classroomio.com');
}
</script>
<div class="root flex items-center justify-center flex-col w-screen">
<Locked size={32} />
<div class="flex flex-col items-center justify-center dark:text-white gap-3 w-4/5 lg:w-2/5">
<p class="text-4xl dark:text-white font-semibold mt-5">Restricted Page</p>
<p class=" text-gray-700 text-lg text-center dark:text-white mb-5">
This organization is restricted. In the mean time, you can go back to the homepage.
</p>
<PrimaryButton
variant={VARIANTS.CONTAINED_DARK}
label="Go to Home"
className="text-lg"
onClick={handleClick}
/>
</div>
</div>
<style>
.root {
height: calc(100vh - 45px);
}
</style>
@@ -228,6 +228,7 @@ export async function getCurrentOrg(siteName: string, justGet = false) {
siteName,
avatar_url,
landingpage,
is_restricted,
customization,
theme,
organization_plan(
+2 -1
View File
@@ -22,7 +22,8 @@ export const defaultCurrentOrgState: CurrentOrg = {
dashboard: { exercise: true, community: true, bannerText: '', bannerImage: '' }
},
theme: '',
organization_plan: []
organization_plan: [],
is_restricted: false
};
export const orgs = writable<CurrentOrg[]>([]);
@@ -33,6 +33,7 @@ export interface CurrentOrg {
plan_name: string;
is_active: boolean;
}[];
is_restricted: boolean;
}
export interface OrgTeamMember {
+4 -1
View File
@@ -16,6 +16,7 @@
import LMSNavigation from '$lib/components/Navigation/lms.svelte';
import OrgLandingPage from '$lib/components/Org/LandingPage/index.svelte';
import Snackbar from '$lib/components/Snackbar/index.svelte';
import Restricted from '$lib/components/Page/Restricted.svelte';
import Backdrop from '$lib/components/Backdrop/index.svelte';
import Apps from '$lib/components/Apps/index.svelte';
import PlayQuiz from '$lib/components/Org/Quiz/Play/index.svelte';
@@ -301,7 +302,9 @@
<UpgradeModal />
<Snackbar />
{#if data.skipAuth}
{#if data.org?.is_restricted}
<Restricted />
{:else if data.skipAuth}
<PlayQuiz />
{:else if data.isOrgSite && !path}
<OrgLandingPage orgSiteName={data.orgSiteName} org={data.org || {}} />
@@ -0,0 +1,27 @@
drop function if exists "public"."convert_course_to_v2"(course_id uuid);
alter table "public"."organization" add column "is_restricted" boolean not null default false;
alter table "public"."profile" add column "is_restricted" boolean not null default false;
set check_function_bodies = off;
CREATE
OR REPLACE FUNCTION convert_course_to_v2 (course_id_arg uuid) RETURNS void AS $$
DECLARE
new_section_id uuid;
BEGIN
UPDATE course
SET version = 'V2'
WHERE id = course_id_arg;
INSERT INTO lesson_section (title, course_id) VALUES ('First Section [edit me]', course_id_arg) RETURNING id INTO new_section_id;
UPDATE lesson
SET section_id = new_section_id
WHERE lesson.course_id = course_id_arg;
END;
$$ LANGUAGE plpgsql;