Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/identity-service/src/routes/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ module.exports = function (app) {

const otpRequired = await requiresOtp({ email })
if (!otpRequired) {
const associatedEmail = await getWalletAssociatedEmail({
req,
authUser: existingUser
})
if (!associatedEmail || email !== associatedEmail.toLowerCase()) {
return errorResponseBadRequest('Invalid credentials')
}
return successResponse(existingUser)
} else if (!otp) {
// use email from registered address if available
Expand Down
19 changes: 19 additions & 0 deletions packages/identity-service/test/authenticationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,25 @@ describe('test authentication routes', function () {
assert.ok(otp)
})

it('only bypasses otp for the associated review email', async function () {
const [authRecord, userRecord] = await signUpUser({
associateWallet: true
})
const email = 'testflight@audius.co'

await request(app)
.get('/authentication')
.query({ lookupKey: authRecord.lookupKey, email })
.expect(400, { error: 'Invalid credentials' })

await userRecord.update({ email })

await request(app)
.get('/authentication')
.query({ lookupKey: authRecord.lookupKey, email })
.expect(200)
})

it('is case-insensitive for OTP code checks', async function () {
await signUpUser()

Expand Down
Loading