fix: admin buttons issue

This commit is contained in:
swve 2023-07-14 11:29:15 +01:00
parent 466616578a
commit 99890a950b
6 changed files with 18 additions and 14 deletions

View file

@ -9,19 +9,21 @@ function GetStarted() {
const { data: install, error: error, isLoading } = useSWR(`${getAPIUrl()}install/latest`, swrFetcher); const { data: install, error: error, isLoading } = useSWR(`${getAPIUrl()}install/latest`, swrFetcher);
const router = useRouter() const router = useRouter()
function startInstallation() { async function startInstallation() {
fetch(`${getAPIUrl()}install/start`, { let res = await fetch(`${getAPIUrl()}install/start`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify({}) body: JSON.stringify({})
}).then(res => res.json()).then(res => { })
if (res.success) {
if (res.status == 200) {
mutate(`${getAPIUrl()}install/latest`) mutate(`${getAPIUrl()}install/latest`)
router.refresh();
router.push(`/install?step=1`) router.push(`/install?step=1`)
} }
})
} }

View file

@ -45,7 +45,7 @@ const CollectionsPage = async (params: any) => {
<GeneralWrapperStyled> <GeneralWrapperStyled>
<div className="flex justify-between" > <div className="flex justify-between" >
<TypeOfContentTitle title="Collections" type="col" /> <TypeOfContentTitle title="Collections" type="col" />
<AuthenticatedClientElement checkMethod='authentication'> <AuthenticatedClientElement checkMethod='roles' orgId={org_id}>
<Link className="flex justify-center" href={getUriWithOrg(orgslug, "/collections/new")}> <Link className="flex justify-center" href={getUriWithOrg(orgslug, "/collections/new")}>
<button className="rounded-md bg-black antialiased ring-offset-purple-800 p-2 px-5 my-auto font text-sm font-bold text-white drop-shadow-lg">Add Collection + </button> <button className="rounded-md bg-black antialiased ring-offset-purple-800 p-2 px-5 my-auto font text-sm font-bold text-white drop-shadow-lg">Add Collection + </button>
</Link> </Link>

View file

@ -20,6 +20,7 @@ import { getCourseThumbnailMediaDirectory } from '@services/media/media';
interface CourseProps { interface CourseProps {
orgslug: string; orgslug: string;
courses: any; courses: any;
org_id: string;
} }
// function to remove "course_" from the course_id // function to remove "course_" from the course_id
@ -49,7 +50,7 @@ function Courses(props: CourseProps) {
<GeneralWrapperStyled> <GeneralWrapperStyled>
<div className='flex flex-wrap justify-between'> <div className='flex flex-wrap justify-between'>
<TypeOfContentTitle title="Courses" type="cou" /> <TypeOfContentTitle title="Courses" type="cou" />
<AuthenticatedClientElement checkMethod='authentication'> <AuthenticatedClientElement checkMethod='roles' orgId={props.org_id}>
<Modal <Modal
isDialogOpen={newCourseModal} isDialogOpen={newCourseModal}
onOpenChange={setNewCourseModal} onOpenChange={setNewCourseModal}

View file

@ -25,13 +25,14 @@ export async function generateMetadata(
const CoursesPage = async (params: any) => { const CoursesPage = async (params: any) => {
const orgslug = params.params.orgslug; const orgslug = params.params.orgslug;
const org = await getOrganizationContextInfo(orgslug, { revalidate: 1800, tags: ['organizations'] });
const cookieStore = cookies(); const cookieStore = cookies();
const access_token_cookie: any = cookieStore.get('access_token_cookie'); const access_token_cookie: any = cookieStore.get('access_token_cookie');
const courses = await getOrgCoursesWithAuthHeader(orgslug, { revalidate: 0, tags: ['courses'] }, access_token_cookie ? access_token_cookie.value : null); const courses = await getOrgCoursesWithAuthHeader(orgslug, { revalidate: 0, tags: ['courses'] }, access_token_cookie ? access_token_cookie.value : null);
return ( return (
<div> <div>
<Courses orgslug={orgslug} courses={courses} /> <Courses org_id={org.org_id} orgslug={orgslug} courses={courses} />
</div> </div>
); );
}; };

View file

@ -14,7 +14,7 @@ export const AuthenticatedClientElement = (props: AuthenticatedClientElementProp
// Available roles // Available roles
const org_roles_values = ["admin", "owner"]; const org_roles_values = ["admin", "owner"];
const user_roles_values = ["role_admin", "role_super_admin"]; const user_roles_values = ["role_admin"];

View file

@ -18,7 +18,7 @@ class Settings(BaseModel):
authjwt_secret_key: str = "secret" if isDevModeEnabled() else SECRET_KEY authjwt_secret_key: str = "secret" if isDevModeEnabled() else SECRET_KEY
authjwt_token_location = {"cookies", "headers"} authjwt_token_location = {"cookies", "headers"}
authjwt_cookie_csrf_protect = False authjwt_cookie_csrf_protect = False
authjwt_access_token_expires = False if isDevModeEnabled() else 3600 authjwt_access_token_expires = False if isDevModeEnabled() else 28800
authjwt_cookie_samesite = "lax" authjwt_cookie_samesite = "lax"
authjwt_cookie_secure = True authjwt_cookie_secure = True
authjwt_cookie_domain = get_learnhouse_config().hosting_config.cookie_config.domain authjwt_cookie_domain = get_learnhouse_config().hosting_config.cookie_config.domain