File tree Expand file tree Collapse file tree
tests/end-to-end/api/methods Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @rocket.chat/meteor ' : minor
3+ ---
4+
5+ Allows users to enable TOTP-based two factor authentication without requiring a verified email address.
Original file line number Diff line number Diff line change @@ -26,14 +26,6 @@ Meteor.methods<ServerMethods>({
2626 } ) ;
2727 }
2828
29- const hasUnverifiedEmail = user . emails ?. some ( ( email ) => ! email . verified ) ;
30-
31- if ( hasUnverifiedEmail ) {
32- throw new Meteor . Error ( 'error-invalid-user' , 'You need to verify your emails before setting up 2FA' , {
33- method : '2fa:enable' ,
34- } ) ;
35- }
36-
3729 if ( user . services ?. totp ?. enabled ) {
3830 throw new Meteor . Error ( 'error-2fa-already-enabled' ) ;
3931 }
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ describe('2fa:enable', function () {
5252 } ) ;
5353 } ) ;
5454
55- it ( 'should return error when user is not verified ' , async ( ) => {
55+ it ( 'should return secret and qr code url even when user has unverified email ' , async ( ) => {
5656 await request
5757 . post ( methodCall ( '2fa:enable' ) )
5858 . set ( user3Credentials )
@@ -66,10 +66,14 @@ describe('2fa:enable', function () {
6666 } )
6767 . expect ( 200 )
6868 . expect ( ( res ) => {
69- expect ( res . body ) . to . have . property ( 'message' ) ;
70- const result = JSON . parse ( res . body . message ) ;
71- expect ( result ) . to . have . property ( 'error' ) ;
72- expect ( result . error ) . to . not . have . property ( 'errpr' , 'error-invalid-user' ) ;
69+ expect ( res . body ) . to . have . property ( 'success' , true ) ;
70+ const parsedBody = JSON . parse ( res . body . message ) ;
71+ expect ( parsedBody ) . to . have . property ( 'result' ) ;
72+ expect ( parsedBody . result ) . to . have . property ( 'secret' ) . of . a ( 'string' ) ;
73+ expect ( parsedBody . result )
74+ . to . have . property ( 'url' )
75+ . of . a ( 'string' )
76+ . match ( / ^ o t p a u t h : \/ \/ / ) ;
7377 } ) ;
7478 } ) ;
7579
You can’t perform that action at this time.
0 commit comments