Skip to content

Commit 8b34089

Browse files
committed
fix: double check user kyc status
1 parent 22ff24a commit 8b34089

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/wallet/backend/src/account/service.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class AccountService implements IAccountService {
9595
assetId: args.assetId,
9696
assetScale: asset.scale,
9797
gateHubWalletId,
98-
card: args.cardId
98+
cardId: args.cardId
9999
})
100100

101101
// On creation account will have balance 0
@@ -111,8 +111,6 @@ export class AccountService implements IAccountService {
111111
): Promise<Account[]> {
112112
const user = await User.query().findById(userId)
113113

114-
console.log('user', JSON.stringify(user, null, 2))
115-
116114
// NOT HERE
117115
if (!user || !user.gateHubUserId) {
118116
throw new NotFound()
@@ -204,8 +202,6 @@ export class AccountService implements IAccountService {
204202
.findById(account.userId)
205203
.select('gateHubUserId')
206204

207-
console.log('getAccountBalance - user', JSON.stringify(user, null, 2))
208-
209205
if (!user || !user.gateHubUserId) {
210206
throw new NotFound()
211207
}

packages/wallet/backend/src/middleware/isAuth.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { NextFunction, Request, Response } from 'express'
22
import { Unauthorized } from '@shared/backend'
3+
import { User } from '@/user/model'
34

45
const KYCRoutes = ['/iframe-urls/onboarding', '/gatehub/add-user-to-gateway']
56

@@ -15,7 +16,13 @@ export const isAuth = async (
1516
}
1617

1718
if (!KYCRoutes.includes(req.url) && req.session.user.needsIDProof) {
18-
throw new Unauthorized('Unauthorized')
19+
const user = await User.query().findById(req.session.user.id)
20+
if (user?.kycVerified) {
21+
req.session.user.needsIDProof = false
22+
await req.session.save()
23+
} else {
24+
throw new Unauthorized('Unauthorized')
25+
}
1926
}
2027
} catch (e) {
2128
next(e)

0 commit comments

Comments
 (0)