This repository was archived by the owner on Apr 3, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +69
-3
lines changed Expand file tree Collapse file tree 6 files changed +69
-3
lines changed Original file line number Diff line number Diff line change @@ -1956,6 +1956,30 @@ module.exports = function (config, DB) {
19561956 } )
19571957 } )
19581958
1959+ it ( 'should update session verificationMethod' , ( ) => {
1960+ const verifyOptions = {
1961+ verificationMethod : 'totp-2fa'
1962+ }
1963+ return db . verifyTokens ( sessionToken . tokenVerificationId , account )
1964+ . then ( ( ) => {
1965+ return db . sessionToken ( tokenId )
1966+ } , assert . fail )
1967+ . then ( ( token ) => {
1968+ assert . equal ( token . mustVerify , false , 'mustVerify is false' )
1969+ assert . equal ( token . tokenVerificationId , null , 'tokenVerificationId is null' )
1970+ assert . equal ( token . verificationMethod , null , 'verificationMethod is null' )
1971+ return db . verifyTokensWithMethod ( tokenId , verifyOptions )
1972+ } )
1973+ . then ( ( ) => {
1974+ return db . sessionToken ( tokenId )
1975+ } , assert . fail )
1976+ . then ( ( token ) => {
1977+ assert . equal ( token . mustVerify , false , 'mustVerify is false' )
1978+ assert . equal ( token . tokenVerificationId , null , 'tokenVerificationId is null' )
1979+ assert . equal ( token . verificationMethod , 2 , 'verificationMethod is set' )
1980+ } )
1981+ } )
1982+
19591983 it ( 'should fail to verify unknown verification method' , ( ) => {
19601984 const verifyOptions = {
19611985 verificationMethod : 'super-invalid-method'
Original file line number Diff line number Diff line change @@ -558,7 +558,7 @@ module.exports = function (log, error) {
558558 item . authAt = sessionTokens [ id ] . authAt || sessionTokens [ id ] . createdAt
559559 item . verificationMethod = sessionTokens [ id ] . verificationMethod || null
560560 item . verifiedAt = sessionTokens [ id ] . verifiedAt || null
561- item . mustVerify = sessionTokens [ id ] . mustVerify || null
561+ item . mustVerify = ! ! sessionTokens [ id ] . mustVerify
562562
563563 var accountId = sessionTokens [ id ] . uid . toString ( 'hex' )
564564 var account = accounts [ accountId ]
Original file line number Diff line number Diff line change @@ -1388,7 +1388,7 @@ module.exports = function (log, error) {
13881388 } )
13891389 }
13901390
1391- const VERIFY_SESSION_WITH_METHOD = 'CALL verifyTokensWithMethod_1 (?, ?, ?)'
1391+ const VERIFY_SESSION_WITH_METHOD = 'CALL verifyTokensWithMethod_2 (?, ?, ?)'
13921392 MySql . prototype . verifyTokensWithMethod = function ( tokenId , data ) {
13931393 return P . resolve ( )
13941394 . then ( ( ) => {
Original file line number Diff line number Diff line change 44
55// The expected patch level of the database. Update if you add a new
66// patch in the ./schema/ directory.
7- module . exports . level = 75
7+ module . exports . level = 76
Original file line number Diff line number Diff line change 1+ SET NAMES utf8mb4 COLLATE utf8mb4_bin;
2+
3+ CREATE PROCEDURE ` verifyTokensWithMethod_2` (
4+ IN ` tokenIdArg` BINARY(32 ),
5+ IN ` verificationMethodArg` INT ,
6+ IN ` verifiedAtArg` BIGINT (1 )
7+ )
8+ BEGIN
9+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
10+ BEGIN
11+ ROLLBACK ;
12+ RESIGNAL;
13+ END;
14+
15+ START TRANSACTION ;
16+ -- Update session verification methods
17+ UPDATE ` sessionTokens` SET verificationMethod = verificationMethodArg, verifiedAt = verifiedAtArg
18+ WHERE tokenId = tokenIdArg;
19+
20+ SET @updateCount = (SELECT ROW_COUNT());
21+
22+ -- Get the tokenVerificationId and uid for session
23+ SET @tokenVerificationId = NULL ;
24+ SET @uid = NULL ;
25+ SELECT tokenVerificationId, uid INTO @tokenVerificationId, @uid FROM ` unverifiedTokens`
26+ WHERE tokenId = tokenIdArg;
27+
28+ -- Verify tokens with tokenVerificationId
29+ CALL verifyToken_3(@tokenVerificationId, @uid);
30+ COMMIT ;
31+
32+ SELECT @updateCount;
33+ END;
34+
35+ UPDATE dbMetadata SET value = ' 76' WHERE name = ' schema-patch-level' ;
36+
Original file line number Diff line number Diff line change 1+ -- SET NAMES utf8mb4 COLLATE utf8mb4_bin;
2+
3+ -- DROP PROCEDURE verifyTokensWithMethod_2;
4+
5+ -- UPDATE dbMetadata SET value = '75' WHERE name = 'schema-patch-level';
6+
You can’t perform that action at this time.
0 commit comments