fix: auth flow bug on joining course
This commit is contained in:
@@ -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 } = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>'
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user