Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typeorm): make the services attribute consistent with mongodb #1111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blessanabraham
Copy link
Contributor

  • Updated the getServices method on the User entity to construct
    objects for the top level fields
  • Added special handling for email.verificationTokens and
    password.reset
  • Updated tests to match the mongodb tests

Fixes: #1110

* Updated the `getServices` method on the `User` entity to construct
objects for the top level fields
* Added special handling for `email.verificationTokens` and
`password.reset`
* Updated tests to match the mongodb tests

Fixes: accounts-js#1110
@blessanabraham
Copy link
Contributor Author

blessanabraham commented Feb 5, 2021

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
Copy link

codecov bot commented Feb 5, 2021

Codecov Report

Merging #1111 (0802624) into master (232de32) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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%) ⬆️
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.

@pradel
Copy link
Member

pradel commented Feb 6, 2021

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 #1081

@pradel
Copy link
Member

pradel commented Feb 6, 2021

@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?

@blessanabraham
Copy link
Contributor Author

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.

@blessanabraham
Copy link
Contributor Author

blessanabraham commented Feb 7, 2021

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.

@pradel
Copy link
Member

pradel commented May 6, 2021

@blessanabraham if you have time to add the tests I can create a release after it's merged with the changes :)

@blessanabraham
Copy link
Contributor Author

Hey @pradel , really sorry for the delay on this. Work was a bit hectic. I'll get to it this week

@darkbasic
Copy link
Member

@blessanabraham could you please rebase against current master and add some tests so that we can get this in the upcoming 1.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TwoFactor service fails with typeorm
3 participants