Skip to content

Commit 1143ad3

Browse files
committed
fix apiKey error
1 parent d34df98 commit 1143ad3

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

backend/database/mock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
name: 'Igor Halfeld',
66
77
password: '1234',
8-
apiKey: 'fcd5015c-10d3-4e9c-b395-ec7ed8850165',
8+
apiKey: ['fcd5015c-10d3-4e9c-b395-ec7ed8850165'],
99
createdAt: new Date('2020-09-05').getTime()
1010
}
1111
],

backend/handlers/feedbacks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function CreateFeedbackHandler (db) {
8484
}
8585

8686
feedbacks = feedbacks.filter((feedback) => {
87-
return feedback.apiKey === user.apiKey
87+
return user.apiKey.includes(feedback.apiKey)
8888
})
8989

9090
if (type) {
@@ -128,7 +128,7 @@ function CreateFeedbackHandler (db) {
128128
}
129129

130130
feedbacks = feedbacks.filter((feedback) => {
131-
return feedback.apiKey === user.apiKey
131+
return user.apiKey.includes(feedback.apiKey)
132132
})
133133

134134
if (type) {

backend/handlers/users.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ function CreateUserHandler (db) {
2121
const apiKey = uuidv4()
2222
const { id } = ctx.state.user
2323

24-
const updated = await db.update('users', id, { apiKey })
24+
const user = await db.readOneById('users', id)
25+
const updated = await db.update('users', id, {
26+
apiKey: [...user.apikey, apiKey]
27+
})
2528
if (updated) {
2629
ctx.status = 202
2730
ctx.body = { apiKey }
@@ -55,7 +58,7 @@ function CreateUserHandler (db) {
5558
name,
5659
email,
5760
password,
58-
apikey: uuidv4(),
61+
apikey: [uuidv4()],
5962
createdAt: new Date().getTime()
6063
}
6164

0 commit comments

Comments
 (0)