mirror of
https://github.com/p-stream/backend.git
synced 2026-01-11 20:10:33 +00:00
35 lines
784 B
TypeScript
35 lines
784 B
TypeScript
import { useAuth } from '~/utils/auth';
|
|
|
|
export default defineEventHandler(async event => {
|
|
const session = await useAuth().getCurrentSession();
|
|
|
|
const user = await prisma.users.findUnique({
|
|
where: { id: session.user },
|
|
});
|
|
|
|
if (!user) {
|
|
throw createError({
|
|
statusCode: 404,
|
|
message: 'User not found',
|
|
});
|
|
}
|
|
|
|
return {
|
|
user: {
|
|
id: user.id,
|
|
publicKey: user.public_key,
|
|
namespace: user.namespace,
|
|
profile: user.profile,
|
|
permissions: user.permissions,
|
|
},
|
|
session: {
|
|
id: session.id,
|
|
user: session.user,
|
|
createdAt: session.created_at,
|
|
accessedAt: session.accessed_at,
|
|
expiresAt: session.expires_at,
|
|
device: session.device,
|
|
userAgent: session.user_agent,
|
|
},
|
|
};
|
|
});
|