···11-import { FreshContext } from "$fresh/server.ts";
22-33-// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/
44-const JOKES = [
55- "Why do Java developers often wear glasses? They can't C#.",
66- "A SQL query walks into a bar, goes up to two tables and says “can I join you?”",
77- "Wasn't hard to crack Forrest Gump's password. 1forrest1.",
88- "I love pressing the F5 key. It's refreshing.",
99- "Called IT support and a chap from Australia came to fix my network connection. I asked “Do you come from a LAN down under?”",
1010- "There are 10 types of people in the world. Those who understand binary and those who don't.",
1111- "Why are assembly programmers often wet? They work below C level.",
1212- "My favourite computer based band is the Black IPs.",
1313- "What programme do you use to predict the music tastes of former US presidential candidates? An Al Gore Rhythm.",
1414- "An SEO expert walked into a bar, pub, inn, tavern, hostelry, public house.",
1515-];
1616-1717-export const handler = (_req: Request, _ctx: FreshContext): Response => {
1818- const randomIndex = Math.floor(Math.random() * JOKES.length);
1919- const body = JOKES[randomIndex];
2020- return new Response(body);
2121-};
+37
routes/api/oauth/callback.ts
···11+import { Handlers } from "$fresh/server.ts"
22+import { oauthClient } from "../../../oauth/client.ts";
33+import { getSession } from "../../../oauth/session.ts"
44+55+export const handler: Handlers = {
66+ async GET(_req) {
77+ const params = new URLSearchParams(_req.url.split("?")[1]);
88+ const url = new URL(_req.url);
99+1010+ try {
1111+ const { session } = await oauthClient.callback(params);
1212+ // Use the common session options
1313+ const clientSession = await getSession(_req);
1414+1515+ // Set the DID on the session
1616+ clientSession.did = session.did;
1717+ await clientSession.save();
1818+1919+ // Get the origin and determine appropriate redirect
2020+ const host = params.get("host");
2121+ const protocol = url.protocol || "http";
2222+ const baseUrl = `${protocol}://${host}`;
2323+2424+ console.info(
2525+ `OAuth callback successful, redirecting to ${baseUrl}/oauth-callback`,
2626+ );
2727+2828+ // Redirect to the frontend oauth-callback page
2929+3030+ return Response.redirect("/login/callback");
3131+ } catch (err) {
3232+ console.error({ err }, "oauth callback failed");
3333+3434+ return Response.redirect("/oauth-callback?error=auth");
3535+ }
3636+ }
3737+}
···11+@import url("https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,200;1,300;1,400;1,500;1,600;1,700;1,800&display=swap");
22+13@tailwind base;
24@tailwind components;
33-@tailwind utilities;55+@tailwind utilities;
66+77+@keyframes fadeOut {
88+ 0% {
99+ opacity: 1;
1010+ }
1111+ 75% {
1212+ opacity: 1;
1313+ } /* Hold full opacity for most of the animation */
1414+ 100% {
1515+ opacity: 0;
1616+ }
1717+}
1818+1919+.status-message-fade {
2020+ animation: fadeOut 2s forwards;
2121+}
2222+2323+.font-spectral {
2424+ font-family: "Spectral", serif;
2525+}
2626+2727+.grow-wrap {
2828+ /* easy way to plop the elements on top of each other and have them both sized based on the tallest one's height */
2929+ display: grid;
3030+}
3131+.grow-wrap::after {
3232+ /* Note the weird space! Needed to preventy jumpy behavior */
3333+ content: attr(data-replicated-value) " ";
3434+3535+ /* This is how textarea text behaves */
3636+ white-space: pre-wrap;
3737+3838+ /* Hidden from view, clicks, and screen readers */
3939+ visibility: hidden;
4040+}
4141+.grow-wrap > textarea {
4242+ /* You could leave this, but after a user resizes, then it ruins the auto sizing */
4343+ resize: none;
4444+4545+ /* Firefox shows scrollbar on growth, you can hide like this. */
4646+ overflow: hidden;
4747+}
4848+.grow-wrap > textarea,
4949+.grow-wrap::after {
5050+ /* Identical styling required!! */
5151+ font: inherit;
5252+5353+ /* Place on top of each other */
5454+ grid-area: 1 / 1 / 2 / 2;
5555+}
5656+5757+/* Base styling */
5858+@layer base {
5959+ body {
6060+ @apply bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100;
6161+ }
6262+ button {
6363+ @apply rounded-xl;
6464+ }
6565+}