Comments (7)
This is done intentionally, due to the way mongodb treats unique indexes. mongoose-auth sets up email as a unique index, so you avoid scenarios where the same email can sign up twice. So we are forced to deal with the way that mongodb treats unique indexes. MongoDB itself (not mongoose itself) handles unique indexes in the following way:
If you were to save a User document with no email, then mongodb automatically fills it in with null
. Mongodb treats null
s with the same unique index constraints, so if you try registering another user also e.g., via facebook, without saving an email, then mongodb will refuse to save it because you will just have tried to save a 2nd document that also has the email value null
.
I chose to fill in a default value for the email field of "#{module_name}:#{unique_id_with_provider}", because that is unique across all documents and will not violate uniqueness constraints.
from mongoose-auth.
OK I got you, what about something like this as format 100000647911219@fb
so I can parse the field like this (in case i ever need to)
var temp = "100000647911219@fb".split("@"); var tempId = temp[0]; var registeredFrom = temp[1];
At the same time is invalid email but its verbose "xxxxx number at facebook". I am not saying this is important but it makes a bit more sence in case someone want to do something crazy like knowing how much users from facebook hasn't register an email address.
I am just saying :-)
JB
from mongoose-auth.
In this case, it's better as the current colon delimited version. You can split on ":" if you need to. More importantly, because you lead with the source name instead of the provider uid, you can leverage mongodb's indexes for faster counting and lookup instead of doing the counting in the client or app.
from mongoose-auth.
Great point about leverage mongodb's indexes, I was thinking more about the extra space after the colon but I can live with that. Thank you Brian for your quick replies.
from mongoose-auth.
Ohh another thing just make sure you add all this great info to the README, for people to be aware and not bother you ;)
from mongoose-auth.
The extra space after the colon is a typo in my code. Will patch that.
from mongoose-auth.
Ahh ok nice! Thank you Brian.
Howdy from Costa Rica!
JB
from mongoose-auth.
Related Issues (20)
- Doesn't install out-of-the-box on Windows (without cygwin) HOT 3
- Is this project still being maintained? HOT 8
- problem installing mongoose-auth on Mac OSX HOT 3
- routing with password authentication?
- Cannot find module 'bcrypt' in nodejs application ? HOT 1
- How do I fix this? getAccessToken of `twitter` module timed out.
- mongooseauth cant install in Windows npm HOT 1
- Node 0.8.0, OSX, bcrypt installs but won't load, wrong architecture HOT 2
- Not able to register new user HOT 1
- Examples on the site incompatible with the latest version of express
- Error with everyauth after 0.3 version update HOT 8
- "everyauth is not defined" error when using view helpers HOT 1
- Installation fails on Linux64 HOT 2
- Where I can found the createWithFB method described on the README.
- Broken out of the box.
- Workin example in Rails
- Error on running example
- Error running example HOT 3
- Don't create a session after registering HOT 2
- problem with loginWith
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose-auth.