Skip to content

Commit

Permalink
feat: support mocking addresses on dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
marian2js committed Nov 3, 2023
1 parent 9327ef5 commit 901a951
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/api/src/auth/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export class AuthService {
}

async validateUserWithSignature(message: string, signature: string): Promise<{ user?: User; fields?: SiweMessage }> {
// For ease of development, allow a mock address to be used
if (process.env.NODE_ENV === 'development' && process.env.MOCK_ADDRESS) {
const user = await this.userService.findOne({ address: process.env.MOCK_ADDRESS })
return user ? { user } : {}
}

const { fields, externalApp } = await this.validateSignature(message, signature, null, true)
const user = await this.userService.findOne({ address: getAddress(fields.address) })
if (user && user.nonces.includes(fields.nonce)) {
Expand Down

0 comments on commit 901a951

Please sign in to comment.