Skip to content

Commit

Permalink
just for good measure
Browse files Browse the repository at this point in the history
  • Loading branch information
lassejaco committed Oct 2, 2024
1 parent aafb2b6 commit 9fb543c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions devcon-api/src/controllers/push-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ pushNotificationRouter.post('/send-notification', sendPushNotification)
async function subscribeToPushNotifications(req: Request, res: Response) {
const userId = req.session.userId

// Temporary block, we'll add auth later
if (process.env.NODE_ENV !== 'development') {
return res.status(403).send({ status: 403, message: 'Not allowed', data: null })
}

if (!userId && process.env.NODE_ENV !== 'development') {
return res.status(403).send({ code: 403, message: 'Login required.' })
}
Expand Down Expand Up @@ -43,6 +48,11 @@ async function subscribeToPushNotifications(req: Request, res: Response) {
async function unsubscribeFromPushNotifications(req: Request, res: Response) {
const userId = req.session.userId

// Temporary block, we'll add auth later
if (process.env.NODE_ENV !== 'development') {
return res.status(403).send({ status: 403, message: 'Not allowed', data: null })
}

if (!userId && process.env.NODE_ENV !== 'development') {
return res.status(403).send({ code: 403, message: 'Login required.' })
}
Expand Down
1 change: 1 addition & 0 deletions devcon-api/src/db/account.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ model rate_limit {

model PushSubscription {
id String @id @default(uuid())
userId String
endpoint String @unique
auth String
p256dh String
Expand Down

0 comments on commit 9fb543c

Please sign in to comment.