feat: migrate to Better Auth for authentication, update environment variables, and enhance database schema with accounts and sessions
This commit is contained in:
@@ -46,16 +46,16 @@ router.post('/upload-url', async (req, res) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = req.user;
|
||||
const authSession = req.auth;
|
||||
|
||||
if (!user) {
|
||||
if (!authSession?.user) {
|
||||
res.status(401).json({ message: 'Unauthorized' });
|
||||
return;
|
||||
}
|
||||
|
||||
await ensureMinioBucket();
|
||||
|
||||
const objectKey = buildObjectKey(user.userId, parsed.data.fileName, parsed.data.prefix);
|
||||
const objectKey = buildObjectKey(authSession.user.id, parsed.data.fileName, parsed.data.prefix);
|
||||
const uploadUrl = await minioClient.presignedPutObject(minioBucket, objectKey, minioPresignedExpirySeconds);
|
||||
const now = new Date();
|
||||
const expiresAt = new Date(now.getTime() + minioPresignedExpirySeconds * 1000);
|
||||
@@ -63,7 +63,7 @@ router.post('/upload-url', async (req, res) => {
|
||||
const [videoRecord] = await db
|
||||
.insert(videos)
|
||||
.values({
|
||||
userId: user.userId,
|
||||
userId: authSession.user.id,
|
||||
objectKey,
|
||||
bucket: minioBucket,
|
||||
uploadUrl,
|
||||
|
||||
Reference in New Issue
Block a user