Utkarsh Anand
Utkarsh Anand
BABetter Auth
Created by Utkarsh Anand on 4/4/2025 in #help
How to revoke all sessions after reset password from forget password link?
I don't find any way to revoke all logged in sessions of a user after reset password from forget password link. I see there is an method authClient.revokeSessions() to do this but it need an loggedin sesison. Also i think about one other solution to login user using the email and newPassword but there is no way to get the email from the forget password link. Althought i can add an extra searchparam in the link before sending but i am looking for better way.
5 replies
BABetter Auth
Created by Utkarsh Anand on 3/27/2025 in #help
Not able to get session type while using auth.api.getSession({headers: headers()})
I have an turborepo setup with below packages, i am trying to migrate from "next-auth" to "better-auth". I have all auth related code in seperate internal package "packages/auth". I facing very strange issue on which i am stuck from last 2 days. My problem is related to getting types for session, I am using auth.api.getSession to get session on serverside. I have tried everything, even when i am using this in auth.ts file itself it is not giving types. I have tried to use differnt tsconfig. Please help me. My packages:
{
"next": "14.2.1-canary.0",
"typescript": "5.2.2",
"better-auth": "^1.2.5",
"@trpc/server": "11.0.0-rc.332",
"drizzle-orm": "0.40.0",
"pg": "^8.13.0",
"@neondatabase/serverless": "^0.7.2",
}
{
"next": "14.2.1-canary.0",
"typescript": "5.2.2",
"better-auth": "^1.2.5",
"@trpc/server": "11.0.0-rc.332",
"drizzle-orm": "0.40.0",
"pg": "^8.13.0",
"@neondatabase/serverless": "^0.7.2",
}
usage: export const session = await auth.api.getSession({ header: headers() }); type of session object:
const session: {
[x: string]: any;
}
const session: {
[x: string]: any;
}
type of auth.api.getSession on hovering .getSession:
(property) getSession: <boolean>(context: {
headers: Headers;
query?: {
disableCookieCache?: boolean | undefined;
} | undefined;
asResponse?: boolean | undefined;
}) => Promise<{
[x: string]: any;
}> & {
...;
}
(property) getSession: <boolean>(context: {
headers: Headers;
query?: {
disableCookieCache?: boolean | undefined;
} | undefined;
asResponse?: boolean | undefined;
}) => Promise<{
[x: string]: any;
}> & {
...;
}
my tsconfig:
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Default",
"compilerOptions": {
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true,
"strictNullChecks": true
},
"exclude": ["node_modules"]
}
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Default",
"compilerOptions": {
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true,
"strictNullChecks": true
},
"exclude": ["node_modules"]
}
7 replies