accounts
accounts copied to clipboard
fix(typeorm): make the services attribute consistent with mongodb
- Updated the
getServices
method on theUser
entity to construct objects for the top level fields - Added special handling for
email.verificationTokens
andpassword.reset
- Updated tests to match the mongodb tests
Fixes: #1110
The fix is ugly because I had to add special handling for some hard coded fields, namely email.verificationTokens
and password.reset
.
I am open to suggestions if there is a better way to do this. The only idea I have in my head right now is, these fields should be in their own tables and I would recommend the same for mongodb as well, since a document has a size limit of 16 MB with the default storage.
Since we do not have control over the no: of times a password might get reset for a user or the number of email verification tokens sent out, these might exceed the limits.
Codecov Report
Merging #1111 (0802624) into master (232de32) will increase coverage by
0.05%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #1111 +/- ##
==========================================
+ Coverage 95.53% 95.59% +0.05%
==========================================
Files 91 91
Lines 2152 2155 +3
Branches 418 420 +2
==========================================
+ Hits 2056 2060 +4
+ Misses 95 94 -1
Partials 1 1
Impacted Files | Coverage Δ | |
---|---|---|
packages/database-typeorm/src/typeorm.ts | 99.52% <ø> (+0.47%) |
:arrow_up: |
packages/database-typeorm/src/entity/User.ts | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 2450f33...a9e36df. Read the comment docs.
The only idea I have in my head right now is, these fields should be in their own tables and I would recommend the same for mongodb as well, since a document has a size limit of 16 MB with the default storage.
Yes totally agree, for mongo this is already in progress https://github.com/accounts-js/accounts/pull/1081
@blessanabraham can you add some tests with various services for this function? As I am not super familiar with this part of the code I am afraid of breaking stuff. Also from my understanding, this is a breaking change regarding the user format returned right?
sure, will add some tests if they are missing.I had to modify the tests that I previously added. from mongodb to match the response from typeorm. After this change, the tests. from mongodb and typeorm match up. I tested and made sure that TwoFactor works now with typeorm and after this change. But you are right, I think we are missing some integration tests.
Regarding breaking change, no, this change keeps it consistent with what mongodb returns and what the services expect the User
entity to look like. typeorm was broken before this change.
@blessanabraham if you have time to add the tests I can create a release after it's merged with the changes :)
Hey @pradel , really sorry for the delay on this. Work was a bit hectic. I'll get to it this week
@blessanabraham could you please rebase against current master and add some tests so that we can get this in the upcoming 1.0?