wailroth
wailroth
Explore posts from servers
TTCTheo's Typesafe Cult
Created by wailroth on 5/22/2024 in #questions
Advices for an electron app
Hello guys, I have some conceptions issues with electron, Sometimes, my app will be on non connected computer, sometimes, will be connected. My issue is: for non connected, I have to store the data somewhere, I decided on litesql But, for the connnected computer, I have 2 choices: include all sql calls to the app, then setup a sql server somewhere for my customers OR develop an API that will handle all of that. Considering, that for now, it's like 1 customer per computer per enterprise, sometimes 2 so it have to be synchronised For now, I think that a client connection could work, but if I want to scale up, i'll need to develop and API.
7 replies
TTCTheo's Typesafe Cult
Created by wailroth on 10/4/2023 in #questions
NextAuth custom properties for session
Hi guys, there is my nextauth config using drizzle
import {DrizzleAdapter} from "@auth/drizzle-adapter";
import {
DefaultSession,
getServerSession,
type NextAuthOptions,
} from "next-auth";
import DiscordProvider from "next-auth/providers/discord";

import {env} from "@/env.mjs";
import {db} from "@/server/db";
import {pgTable, sessions} from "@/server/db/schema";

/**
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
*
* @see https://next-auth.js.org/configuration/options
*/

declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
isStaff: boolean
} & DefaultSession["user"];
}

interface User {
// ...other properties
isStaff: boolean
}
}

export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
isStaff: user.isStaff
},
}),
},
pages: {
//signOut: '/api/auth/signout',
newUser: "/api/auth/register"

},
adapter: DrizzleAdapter(db, pgTable),
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),

*/
export const getServerAuthSession = () => getServerSession(authOptions);
import {DrizzleAdapter} from "@auth/drizzle-adapter";
import {
DefaultSession,
getServerSession,
type NextAuthOptions,
} from "next-auth";
import DiscordProvider from "next-auth/providers/discord";

import {env} from "@/env.mjs";
import {db} from "@/server/db";
import {pgTable, sessions} from "@/server/db/schema";

/**
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
*
* @see https://next-auth.js.org/configuration/options
*/

declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
isStaff: boolean
} & DefaultSession["user"];
}

interface User {
// ...other properties
isStaff: boolean
}
}

export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
isStaff: user.isStaff
},
}),
},
pages: {
//signOut: '/api/auth/signout',
newUser: "/api/auth/register"

},
adapter: DrizzleAdapter(db, pgTable),
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),

*/
export const getServerAuthSession = () => getServerSession(authOptions);
as you can see, I have normally custom properties like isStaff. But, when I log my session, isStaff or any other propertie is always null
3 replies
TTCTheo's Typesafe Cult
Created by wailroth on 5/2/2023 in #questions
Edit default sign in form
52 replies