This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(db): expunge devices in resetAccount sproc
- Loading branch information
Showing
6 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
-- Previous versions of the resetAccount stored procedure | ||
-- do not expunge devices. This one does. | ||
CREATE PROCEDURE `resetAccount_5` ( | ||
IN `inUid` BINARY(16), | ||
IN `inVerifyHash` BINARY(32), | ||
IN `inAuthSalt` BINARY(32), | ||
IN `inWrapWrapKb` BINARY(32), | ||
IN `inVerifierSetAt` BIGINT UNSIGNED, | ||
IN `inVerifierVersion` TINYINT UNSIGNED | ||
) | ||
BEGIN | ||
|
||
DECLARE EXIT HANDLER FOR SQLEXCEPTION | ||
BEGIN | ||
ROLLBACK; | ||
RESIGNAL; | ||
END; | ||
|
||
START TRANSACTION; | ||
|
||
DELETE FROM sessionTokens WHERE uid = inUid; | ||
DELETE FROM keyFetchTokens WHERE uid = inUid; | ||
DELETE FROM accountResetTokens WHERE uid = inUid; | ||
DELETE FROM passwordChangeTokens WHERE uid = inUid; | ||
DELETE FROM passwordForgotTokens WHERE uid = inUid; | ||
DELETE FROM accountUnlockCodes WHERE uid = inUid; | ||
DELETE FROM devices WHERE uid = inUid; | ||
|
||
UPDATE | ||
accounts | ||
SET | ||
verifyHash = inVerifyHash, | ||
authSalt = inAuthSalt, | ||
wrapWrapKb = inWrapWrapKb, | ||
verifierSetAt = inVerifierSetAt, | ||
verifierVersion = inVerifierVersion | ||
WHERE | ||
uid = inUid | ||
; | ||
|
||
INSERT INTO eventLog( | ||
uid, | ||
typ, | ||
iat | ||
) | ||
VALUES( | ||
inUid, | ||
"reset", | ||
UNIX_TIMESTAMP() | ||
); | ||
|
||
COMMIT; | ||
END; | ||
|
||
|
||
-- Schema patch-level increment. | ||
UPDATE dbMetadata SET value = '22' WHERE name = 'schema-patch-level'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- -- Drop new stored procedures | ||
-- DROP PROCEDURE `resetAccount_5`; | ||
|
||
-- -- Decrement the schema version | ||
-- UPDATE dbMetadata SET value = '21' WHERE name = 'schema-patch-level'; |