fix: auth flow bug on joining course

This commit is contained in:
Rotimi Best
2023-12-05 08:31:26 +03:00
parent 8fc3a5e1fc
commit 6fa1d0fcfb
12 changed files with 69 additions and 86 deletions
@@ -3,7 +3,7 @@ import type { Course } from '../types';
export const isCourseFree = (cost: number) => !(Number(cost) > 0);
export const getStudentInviteLink = (_course: Course, orgSiteName: string) => {
export const getStudentInviteLink = (_course: Course, orgSiteName: string, origin: string) => {
const hash = encodeURIComponent(
btoa(
JSON.stringify({
@@ -15,7 +15,7 @@ export const getStudentInviteLink = (_course: Course, orgSiteName: string) => {
)
);
return `https://${orgSiteName}.classroomio.com/invite/s/${hash}`;
return `${origin}/invite/s/${hash}`;
};
export const getTextFromHTML = (html: string): string => {
@@ -27,7 +27,7 @@ export const getTextFromHTML = (html: string): string => {
return dummyDiv.textContent?.trim() || '';
};
const tagsToReplace = {
const tagsToReplace: { [k: string]: string } = {
'&': '&',
'<': '&lt;',
'>': '&gt;'
+5 -3
View File
@@ -6,8 +6,7 @@ import type { CurrentOrg, OrgTeamMember, OrgAudience } from '../types/org';
import { ROLE } from '$lib/utils/constants/roles';
import type { UserLessonDataType } from '$lib/utils/types';
export const orgs = writable<CurrentOrg[]>([]);
export const currentOrg: Writable<CurrentOrg> = writable({
export const defaultCurrentOrgState: CurrentOrg = {
id: '',
name: '',
shortName: '',
@@ -17,7 +16,10 @@ export const currentOrg: Writable<CurrentOrg> = writable({
role_id: '',
landingpage: {},
theme: ''
});
};
export const orgs = writable<CurrentOrg[]>([]);
export const currentOrg: Writable<CurrentOrg> = writable(defaultCurrentOrgState);
export const orgAudience = writable<OrgAudience[]>([]);
export const orgTeam = writable<OrgTeamMember[]>([]);
export const isOrgAdmin = derived(
+19 -11
View File
@@ -1,21 +1,15 @@
import { writable } from 'svelte/store';
import type { User } from '@supabase/supabase-js';
export const user = writable<{
interface UserStore {
openAuthModal: boolean;
fetchingUser: boolean;
isLoggedIn: boolean;
currentSession: User | undefined;
expiresAt: number;
}>({
openAuthModal: false,
fetchingUser: false,
isLoggedIn: false,
currentSession: undefined,
expiresAt: 0
});
}
export const profile = writable<{
interface ProfileStore {
id: string | undefined;
fullname: string;
avatar_url: string;
@@ -27,7 +21,17 @@ export const profile = writable<{
goal: string;
source: string;
telegram_chat_id: number | null;
}>({
}
export const defaultUserState: UserStore = {
openAuthModal: false,
fetchingUser: false,
isLoggedIn: false,
currentSession: undefined,
expiresAt: 0
};
export const defaultProfileState: ProfileStore = {
id: undefined,
fullname: '',
avatar_url: 'https://pbs.twimg.com/profile_images/1416443682157473795/dGtFbtht_normal.jpg',
@@ -38,4 +42,8 @@ export const profile = writable<{
goal: '',
source: '',
telegram_chat_id: null
});
};
export const user = writable<UserStore>(defaultUserState);
export const profile = writable<ProfileStore>(defaultProfileState);