Compare commits
No commits in common. "dc24968674260cb76f864c7689d564b43ea904f6" and "64a04999112866de2931120eac3558f755a44e65" have entirely different histories.
dc24968674
...
64a0499911
6 changed files with 23 additions and 26 deletions
|
|
@ -1,20 +0,0 @@
|
||||||
type SubmitProps = {
|
|
||||||
eventString: string;
|
|
||||||
text: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function Submit({ eventString, text }: SubmitProps) {
|
|
||||||
function handleClick() {
|
|
||||||
window.dispatchEvent(new Event(`submit-${eventString}`));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={handleClick}
|
|
||||||
className="submit-btn"
|
|
||||||
>
|
|
||||||
⚓︎ {text}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
13
blog/src/islands/auth.server.tsx
Normal file
13
blog/src/islands/auth.server.tsx
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
const isTokenExpired = (token: string): boolean => {
|
||||||
|
try {
|
||||||
|
const { exp } = jwt.decode(token) as { exp: number };
|
||||||
|
const expirationDatetimeInSeconds = exp * 1000;
|
||||||
|
return Date.now() >= expirationDatetimeInSeconds;
|
||||||
|
} catch {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export { isTokenExpired };
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
import NavBack from "../islands/NavBack";
|
import NavBack from "../islands/NavBack";
|
||||||
import Submit from "../islands/Submit";
|
|
||||||
import Main from "../layouts/Main.astro";
|
import Main from "../layouts/Main.astro";
|
||||||
|
|
||||||
const { title, subtitle, text, buttonText, eventString } = Astro.props;
|
const { title, subtitle, text, buttonText, eventString } = Astro.props;
|
||||||
|
|
@ -17,7 +16,12 @@ const { title, subtitle, text, buttonText, eventString } = Astro.props;
|
||||||
<slot />
|
<slot />
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<NavBack client:load />
|
<NavBack client:load />
|
||||||
<Submit eventString={eventString} text={buttonText} client:load />
|
<button
|
||||||
|
onclick={`window.dispatchEvent(new Event("${eventString}"))`}
|
||||||
|
class="submit-btn"
|
||||||
|
>
|
||||||
|
⚓︎ {buttonText}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import Form from "../layouts/Form.astro";
|
||||||
Code ein, denn du nach dem registrieren via E-Mail erhalten
|
Code ein, denn du nach dem registrieren via E-Mail erhalten
|
||||||
hast."
|
hast."
|
||||||
buttonText="Anmelden"
|
buttonText="Anmelden"
|
||||||
eventString="login"
|
eventString="submit-login"
|
||||||
>
|
>
|
||||||
<LoginForm client:load />
|
<LoginForm client:load />
|
||||||
<a href="/register">Noch keinen Account? Hier registrieren</a>
|
<a href="/register">Noch keinen Account? Hier registrieren</a>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import Form from "../layouts/Form.astro";
|
||||||
subtitle="E-Mail Erinnerung für neue Artikel"
|
subtitle="E-Mail Erinnerung für neue Artikel"
|
||||||
text="Endlich könnt E-Mail Erinnerungen erhalten, wenn wir neue Artikel veröffentlichen. Für die spätere Kommentarfunktion fragen wir gleich den Namen mit ab."
|
text="Endlich könnt E-Mail Erinnerungen erhalten, wenn wir neue Artikel veröffentlichen. Für die spätere Kommentarfunktion fragen wir gleich den Namen mit ab."
|
||||||
buttonText="Registrieren"
|
buttonText="Registrieren"
|
||||||
eventString="register"
|
eventString="submit-register"
|
||||||
>
|
>
|
||||||
<RegisterForm client:load/>
|
<RegisterForm client:only/>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import Form from "../layouts/Form.astro";
|
||||||
subtitle="Hier kannst du dein Konto verwalten."
|
subtitle="Hier kannst du dein Konto verwalten."
|
||||||
text=""
|
text=""
|
||||||
buttonText="Speichern"
|
buttonText="Speichern"
|
||||||
eventString="toggle-subscription"
|
eventString="submit-toggle-subscription"
|
||||||
>
|
>
|
||||||
<UserDetails client:load />
|
<UserDetails client:load />
|
||||||
<ToggleSubscription client:load />
|
<ToggleSubscription client:load />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue