mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 12:27:44 +00:00
chore: remove unused code from context (#536)
This commit is contained in:
@@ -50,7 +50,6 @@ exports[`init > should match config 1`] = `
|
||||
},
|
||||
"baseURL": "http://localhost:3000/api/auth",
|
||||
"createAuthCookie": [Function],
|
||||
"db": Kysely {},
|
||||
"internalAdapter": {
|
||||
"createAccount": [Function],
|
||||
"createOAuthUser": [Function],
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import type { Kysely } from "kysely";
|
||||
import { getAuthTables } from "./db/get-tables";
|
||||
import { createKyselyAdapter } from "./adapters/kysely-adapter/dialect";
|
||||
import { getAdapter } from "./db/utils";
|
||||
import { hashPassword, verifyPassword } from "./crypto/password";
|
||||
import { createInternalAdapter } from "./db";
|
||||
@@ -30,7 +28,6 @@ export const init = async (options: BetterAuthOptions) => {
|
||||
const plugins = options.plugins || [];
|
||||
const internalPlugins = getInternalPlugins(options);
|
||||
|
||||
const { kysely: db } = await createKyselyAdapter(options);
|
||||
const baseURL = getBaseURL(options.baseURL, options.basePath);
|
||||
|
||||
const secret =
|
||||
@@ -103,7 +100,6 @@ export const init = async (options: BetterAuthOptions) => {
|
||||
logger: createLogger({
|
||||
disabled: options.logger?.disabled || false,
|
||||
}),
|
||||
db,
|
||||
uuid: generateId,
|
||||
secondaryStorage: options.secondaryStorage,
|
||||
password: {
|
||||
@@ -134,7 +130,6 @@ export type AuthContext = {
|
||||
socialProviders: OAuthProvider[];
|
||||
authCookies: BetterAuthCookies;
|
||||
logger: ReturnType<typeof createLogger>;
|
||||
db: Kysely<any> | null;
|
||||
rateLimit: {
|
||||
enabled: boolean;
|
||||
window: number;
|
||||
|
||||
@@ -297,7 +297,7 @@ export const getOrgAdapter = (
|
||||
/**
|
||||
* @requires db
|
||||
*/
|
||||
findFullOrganization: async (organizationId: string, db?: Kysely<any>) => {
|
||||
findFullOrganization: async (organizationId: string) => {
|
||||
const [org, invitations, members] = await Promise.all([
|
||||
adapter.findOne<Organization>({
|
||||
model: "organization",
|
||||
|
||||
@@ -241,10 +241,7 @@ export const getFullOrganization = createAuthEndpoint(
|
||||
});
|
||||
}
|
||||
const adapter = getOrgAdapter(ctx.context, ctx.context.orgOptions);
|
||||
const organization = await adapter.findFullOrganization(
|
||||
organizationId,
|
||||
ctx.context.db || undefined,
|
||||
);
|
||||
const organization = await adapter.findFullOrganization(organizationId);
|
||||
if (!organization) {
|
||||
throw new APIError("BAD_REQUEST", {
|
||||
message: "Organization not found",
|
||||
@@ -293,10 +290,7 @@ export const setActiveOrganization = createAuthEndpoint(
|
||||
});
|
||||
}
|
||||
await adapter.setActiveOrganization(session.session.id, organizationId);
|
||||
const organization = await adapter.findFullOrganization(
|
||||
organizationId,
|
||||
ctx.context.db || undefined,
|
||||
);
|
||||
const organization = await adapter.findFullOrganization(organizationId);
|
||||
return ctx.json(organization);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user