basic user-tailored UI

This commit is contained in:
Avraham Sakal
2025-09-18 10:45:00 -04:00
parent 83e3f867dd
commit 61540f9338
8 changed files with 43 additions and 34 deletions
+20 -20
View File
@@ -4,7 +4,7 @@ import {
createActionURL,
setEnvDefaults,
} from "@auth/core";
import CredentialsProvider from "@auth/core/providers/credentials";
// import CredentialsProvider from "@auth/core/providers/credentials";
import GoogleProvider from "@auth/core/providers/google";
import type { Session } from "@auth/core/types";
// TODO: stop using universal-middleware and directly integrate server middlewares instead and/or use vike-server https://vike.dev/server. (Bati generates boilerplates that use universal-middleware https://github.com/magne4000/universal-middleware to make Bati's internal logic easier. This is temporary and will be removed soon.)
@@ -41,26 +41,26 @@ const authjsConfig = {
secret: "buginoo",
providers: [
// TODO: Choose and implement providers
CredentialsProvider({
name: "Credentials",
credentials: {
username: { label: "Username", type: "text", placeholder: "jsmith" },
password: { label: "Password", type: "password" },
},
async authorize() {
// Add logic here to look up the user from the credentials supplied
const user = {
id: "019900bb-61b3-7333-b760-b27784dfe33b",
name: "J Smith",
email: "jsmith@example.com",
};
// CredentialsProvider({
// name: "Credentials",
// credentials: {
// username: { label: "Username", type: "text", placeholder: "jsmith" },
// password: { label: "Password", type: "password" },
// },
// async authorize() {
// // Add logic here to look up the user from the credentials supplied
// const user = {
// id: "019900bb-61b3-7333-b760-b27784dfe33b",
// name: "J Smith",
// email: "jsmith@example.com",
// };
// Any object returned will be saved in `user` property of the JWT
// If you return null then an error will be displayed advising the user to check their details.
// You can also Reject this callback with an Error thus the user will be sent to the error page with the error message as a query parameter
return user ?? null;
},
}),
// // Any object returned will be saved in `user` property of the JWT
// // If you return null then an error will be displayed advising the user to check their details.
// // You can also Reject this callback with an Error thus the user will be sent to the error page with the error message as a query parameter
// return user ?? null;
// },
// }),
GoogleProvider({
clientId:
"697711350664-t6237s5n3ttjd1npp1qif1aupptkr0va.apps.googleusercontent.com",
+4 -1
View File
@@ -9,13 +9,14 @@ import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { getDb, getDbClient } from "../database/postgres";
import { getOpenrouter } from "../pages/chat/provider";
import { env as processEnv } from "./env.js";
import { getToken } from "@auth/core/jwt";
export const trpcHandler = ((endpoint) => (request, context, runtime) => {
return fetchRequestHandler({
endpoint,
req: request,
router: appRouter,
createContext({ req, resHeaders }) {
async createContext({ req, resHeaders }) {
const env = getEnv(runtime);
const dbClient = getDbClient(
(env.POSTGRES_CONNECTION_STRING ||
@@ -28,6 +29,7 @@ export const trpcHandler = ((endpoint) => (request, context, runtime) => {
const openrouter = getOpenrouter(
(env.OPENROUTER_API_KEY || processEnv.OPENROUTER_API_KEY) as string
);
const jwt = await getToken({ req: request, secret: "buginoo" });
return {
...context,
...runtime,
@@ -36,6 +38,7 @@ export const trpcHandler = ((endpoint) => (request, context, runtime) => {
dbClient,
db,
openrouter,
jwt,
};
},
allowMethodOverride: true,