Skip to content

Commit

Permalink
Lucia patch
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarscher committed Feb 1, 2024
1 parent ef6d5b5 commit 2616cea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions packages/api/src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@ export const getAllowedOriginHost = (app_url: string, request?: Request) => {
return requestHost === appHost ? appHost : undefined
}

export const createAuth = (db: DB, appUrl: string, apiUrl: string) => {
export const createAuth = (db: DB) => {
// @ts-ignore Expect type errors because this is D1 and not SQLite... but it works
const adapter = new DrizzleSQLiteAdapter(db, SessionTable, UserTable)
// cast probably only needed until adapter-drizzle is updated
const env = !appUrl || appUrl.startsWith('http:') ? 'DEV' : 'PROD'
// @ts-ignore the "none" option for sameSite works... but https://github.com/lucia-auth/lucia/issues/1320
return new Lucia(adapter as Adapter, {
return new Lucia(adapter, {
getUserAttributes: (data: DatabaseUserAttributes) => {
return {
email: data.email || '',
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const createContext = async (

// const user = await getUser()

const auth = createAuth(db, env.APP_URL, env.PUBLIC_API_URL)
const auth = createAuth(db)
const enableTokens = Boolean(context?.req.header('x-enable-tokens'))

async function getSession() {
Expand Down

0 comments on commit 2616cea

Please sign in to comment.