Filippo
Filippo
BABetter Auth
Created by Filippo on 5/22/2025 in #help
How to add properties in the session table
I'd need to add properties to the session table to store last login, os version, browser etc. I've used UAParserJs with Lucia and achieved this, but I'm not familiar with BetterAuth and I need guidance to where implement this functionality. Thanks.
1 replies
BABetter Auth
Created by Filippo on 5/8/2025 in #help
List sessions server side
Hello, I'm making a sveltekit app where after the login input, if credentials are right, the server look for other sessions of the user, if there is another session open (for example in another device's browser) there is a modal that asks for session removal (it's a web app and I need to limit multiple sessions) then the log in proceeds. Is there a way to use authClient.listSessions() on the server? Because I could login the user before and then prompt the session and log out if the other is not removed, but it looks more prone to exploits and I'd prefer server-side operations.
2 replies
BABetter Auth
Created by Filippo on 4/30/2025 in #help
Create new roles and permissions client side
Hello, my app is based on user roles and permissions. I want to create a page where the admin user can create and manage new roles and assign permissions. However, better auth does not have a role and permission tables. Is it possible to do what I have in mind?
7 replies
BABetter Auth
Created by Filippo on 4/23/2025 in #help
How to log in from the server
Hello, I have a login page with a form and I'm trying to signIn the user on the server:
export const actions = {
default: async ({cookies, request}) => {
const email = formData.get("email");
const password = formData.get("password");

try {
const response = await auth.api.signInEmail({
body: { email, password },
asResponse: true
});
return { success: true };
} catch (err) {
return fail(401, { error: 'Invalid credentials' });
}
export const actions = {
default: async ({cookies, request}) => {
const email = formData.get("email");
const password = formData.get("password");

try {
const response = await auth.api.signInEmail({
body: { email, password },
asResponse: true
});
return { success: true };
} catch (err) {
return fail(401, { error: 'Invalid credentials' });
}
I get the success: true, but when I navigate on another page I do
import { auth } from "$lib/auth";

export const load = async ({ request, locals }) => {
const session = await auth.api.getSession({
headers: request.headers
})

console.log(session)
import { auth } from "$lib/auth";

export const load = async ({ request, locals }) => {
const session = await auth.api.getSession({
headers: request.headers
})

console.log(session)
But session is null, what should I do to get the session or cookie created? Thank you
12 replies