-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0e965c
commit ac18724
Showing
18 changed files
with
1,039 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/studiocms_auth/src/components/StaticAuthCheck.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
import { getUserData } from 'studiocms:auth/lib/user'; | ||
import { StudioCMSRoutes } from 'studiocms:helpers/routemap'; | ||
import { getLangFromUrl, useTranslatedPath } from 'studiocms:i18n'; | ||
const { isLoggedIn } = await getUserData(Astro); | ||
// Get the language and translations | ||
const referer = Astro.request.headers.get('referer'); | ||
if (!referer) { | ||
throw new Error('No referer found'); | ||
} | ||
const lang = getLangFromUrl(new URL(referer)); | ||
const translatePath = useTranslatedPath(lang); | ||
const { | ||
mainLinks: { dashboardIndex }, | ||
} = StudioCMSRoutes; | ||
--- | ||
<div | ||
id="login-check" | ||
style="display: none;" | ||
data-isloggedin={`${isLoggedIn}`} | ||
data-redirectroute={translatePath(dashboardIndex)} | ||
></div> | ||
|
||
<script is:inline> | ||
const loginCheck = document.getElementById('login-check'); | ||
|
||
if (loginCheck.dataset.isloggedin === 'true') { | ||
window.location.href = loginCheck.dataset.redirectroute; | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
import { StudioCMSRoutes } from 'studiocms:helpers/routemap'; | ||
import { getLangFromUrl, staticPaths, useTranslations } from 'studiocms:i18n'; | ||
import type { GetStaticPaths } from 'astro'; | ||
import AuthLayout from '../layouts/AuthLayout.astro'; | ||
const lang = getLangFromUrl(Astro.url); | ||
const t = useTranslations(lang, '@studiocms/auth:logout'); | ||
export const getStaticPaths = (() => { | ||
const paths = staticPaths(); | ||
return paths; | ||
}) satisfies GetStaticPaths; | ||
const { | ||
authLinks: { logoutAPI }, | ||
} = StudioCMSRoutes; | ||
--- | ||
<AuthLayout title={t('title')} description={t('description')} lang={lang} disableScreen> | ||
|
||
</AuthLayout> | ||
|
||
<div style="display: none;" id="redirect-to-logout" data-redirect={logoutAPI}></div> | ||
|
||
<script> | ||
|
||
const redirectElement = document.getElementById('redirect-to-logout') as HTMLDivElement; | ||
const redirect = redirectElement.getAttribute('data-redirect') as string; | ||
|
||
setTimeout(() => { | ||
window.location.href = redirect; | ||
}, 500); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.