Skip to content

Commit bb9a1d7

Browse files
authored
Don't Switch tfaSendMethod Automatically (canada-ca#1929)
* remove changing of tfa send method * update verify-account to not auto switch tfa method
1 parent 884873c commit bb9a1d7

3 files changed

Lines changed: 112 additions & 5 deletions

File tree

api-js/src/user/mutations/__tests__/verify-account.test.js

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,64 @@ describe('user send password reset email', () => {
145145
user = await cursor.next()
146146

147147
expect(response).toEqual(expectedResult)
148-
expect(user.emailValidated).toEqual(true)
149148
expect(consoleOutput).toEqual([
150149
`User: ${user._key} successfully email validated their account.`,
151150
])
152151
})
152+
it('sets emailValidated to true', async () => {
153+
let cursor = await query`
154+
FOR user IN users
155+
FILTER user.userName == "test.account@istio.actually.exists"
156+
RETURN user
157+
`
158+
let user = await cursor.next()
159+
160+
const token = tokenize({ parameters: { userKey: user._key } })
161+
162+
await graphql(
163+
schema,
164+
`
165+
mutation {
166+
verifyAccount(input: { verifyTokenString: "${token}" }) {
167+
result {
168+
... on VerifyAccountResult {
169+
status
170+
}
171+
... on VerifyAccountError {
172+
code
173+
description
174+
}
175+
}
176+
}
177+
}
178+
`,
179+
null,
180+
{
181+
i18n,
182+
request,
183+
userKey: user._key,
184+
query,
185+
auth: {
186+
verifyToken: verifyToken({}),
187+
},
188+
validators: {
189+
cleanseInput,
190+
},
191+
loaders: {
192+
userLoaderByKey: userLoaderByKey(query),
193+
},
194+
},
195+
)
196+
197+
cursor = await query`
198+
FOR user IN users
199+
FILTER user.userName == "test.account@istio.actually.exists"
200+
RETURN user
201+
`
202+
user = await cursor.next()
203+
204+
expect(user.emailValidated).toEqual(true)
205+
})
153206
})
154207
describe('given an unsuccessful validation', () => {
155208
describe('userKey is undefined', () => {
@@ -660,6 +713,60 @@ describe('user send password reset email', () => {
660713
`User: ${user._key} successfully email validated their account.`,
661714
])
662715
})
716+
it('sets emailValidated to true', async () => {
717+
let cursor = await query`
718+
FOR user IN users
719+
FILTER user.userName == "test.account@istio.actually.exists"
720+
RETURN user
721+
`
722+
let user = await cursor.next()
723+
724+
const token = tokenize({ parameters: { userKey: user._key } })
725+
726+
await graphql(
727+
schema,
728+
`
729+
mutation {
730+
verifyAccount(input: { verifyTokenString: "${token}" }) {
731+
result {
732+
... on VerifyAccountResult {
733+
status
734+
}
735+
... on VerifyAccountError {
736+
code
737+
description
738+
}
739+
}
740+
}
741+
}
742+
`,
743+
null,
744+
{
745+
i18n,
746+
request,
747+
userKey: user._key,
748+
query,
749+
auth: {
750+
verifyToken: verifyToken({}),
751+
},
752+
validators: {
753+
cleanseInput,
754+
},
755+
loaders: {
756+
userLoaderByKey: userLoaderByKey(query),
757+
},
758+
},
759+
)
760+
761+
cursor = await query`
762+
FOR user IN users
763+
FILTER user.userName == "test.account@istio.actually.exists"
764+
RETURN user
765+
`
766+
user = await cursor.next()
767+
768+
expect(user.emailValidated).toEqual(true)
769+
})
663770
})
664771
describe('given an unsuccessful validation', () => {
665772
describe('userKey is undefined', () => {

api-js/src/user/mutations/verify-account.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ export const verifyAccount = new mutationWithClientMutationId({
100100
try {
101101
await query`
102102
UPSERT { _key: ${user._key} }
103-
INSERT { emailValidated: true, tfaSendMethod: 'email' }
104-
UPDATE { emailValidated: true, tfaSendMethod: 'email' }
103+
INSERT { emailValidated: true }
104+
UPDATE { emailValidated: true }
105105
IN users
106106
`
107107
} catch (err) {

api-js/src/user/mutations/verify-phone-number.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export const verifyPhoneNumber = new mutationWithClientMutationId({
6666
try {
6767
await query`
6868
UPSERT { _key: ${user._key} }
69-
INSERT { phoneValidated: true, tfaSendMethod: 'phone' }
70-
UPDATE { phoneValidated: true, tfaSendMethod: 'phone' }
69+
INSERT { phoneValidated: true }
70+
UPDATE { phoneValidated: true }
7171
IN users
7272
`
7373
} catch (err) {

0 commit comments

Comments
 (0)