Skip to content

Commit

Permalink
feat(apple): return http 200 when serial number is already registered (
Browse files Browse the repository at this point in the history
  • Loading branch information
aahna-ashina committed Sep 12, 2022
1 parent f722672 commit 848304e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions server/cypress/e2e/api/apple/[serialNumber].cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe('Register a Pass for Update Notifications', () => {
},
failOnStatusCode: false
}).then((response) => {
expect(response.status).to.eq(401)
expect(JSON.stringify(response.body)).to.contain('Request Not Authorized: duplicate key value violates unique constraint')
expect(response.status).to.eq(200)
expect(JSON.stringify(response.body)).to.contain('Serial Number Already Registered for Device')
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
.then((result: any) => {
console.log('result:', result)
if (result.error) {
res.status(401).json({
error: 'Request Not Authorized: ' + result.error.message
})
return
if (result.error.message.includes('duplicate key value violates unique constraint')) {
res.status(200).json({
error: 'Serial Number Already Registered for Device'
})
} else {
res.status(500).json({
error: 'Internal Server Error: ' + result.error.message
})
}
} else {
res.status(201).json({
message: 'Registration Successful'
Expand Down

0 comments on commit 848304e

Please sign in to comment.