lingthio / Flask-User

Customizable User Authorization & User Management: Register, Confirm, Login, Change username/password, Forgot password and more.
http://flask-user.readthedocs.io/
MIT License
1.06k stars 294 forks source link

Mongodb error when creating user with email #247

Open helgisteinar opened 5 years ago

helgisteinar commented 5 years ago

Setup: USER_ENABLE_EMAIL = True # Disable email authentication USER_ENABLE_USERNAME = False # Enable username authentication USER_REQUIRE_RETYPE_PASSWORD = False # Simplify register form

Description: When trying to create a user, a Mongodb lookup failed.

Error: Traceback (most recent call last): File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/app.py", line 2309, in call return self.wsgi_app(environ, start_response) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/app.py", line 2295, in wsgi_app response = self.handle_exception(e) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise raise value File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise raise value File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functionsrule.endpoint File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask_user/user_manager.py", line 423, in register_stub return self.register_view() File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask_user/user_managerviews.py", line 461, in register_view if request.method == 'POST' and register_form.validate(): File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask_user/forms.py", line 286, in validate if not super(RegisterForm, self).validate(): File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/wtforms/form.py", line 310, in validate return super(Form, self).validate(extra) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/wtforms/form.py", line 152, in validate if not field.validate(self, extra): File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/wtforms/fields/core.py", line 206, in validate stop_validation = self._run_validation_chain(form, chain) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/wtforms/fields/core.py", line 226, in _run_validation_chain validator(form, self) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask_user/forms.py", line 47, in unique_email_validator if not user_manager.email_is_available(field.data): File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask_user/user_managerutils.py", line 43, in email_is_available user, user_email = self.db_manager.get_user_and_user_email_by_email(new_email) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask_user/db_manager.py", line 175, in get_user_and_user_email_by_email user = self.db_adapter.ifind_first_object(self.UserClass, email=email) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/flask_user/db_adapters/mongo_db_adapter.py", line 82, in ifind_first_object return ObjectClass.objects(iexact_kwargs).first() File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/mongoengine/queryset/base.py", line 294, in first result = queryset[0] File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/mongoengine/queryset/base.py", line 194, in getitem queryset._cursor[key], File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/mongoengine/queryset/base.py", line 1567, in _cursor self._cursor_obj = self._collection.find(self._query, File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/mongoengine/queryset/base.py", line 1613, in _query self._mongo_query = self._query_obj.to_query(self._document) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/mongoengine/queryset/visitor.py", line 89, in to_query query = query.accept(QueryCompilerVisitor(document)) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/mongoengine/queryset/visitor.py", line 162, in accept return visitor.visit_query(self) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/mongoengine/queryset/visitor.py", line 78, in visit_query return transform.query(self.document, query.query) File "/Users/hs/Documents/SocialIdentity/socid/env/lib/python3.7/site-packages/mongoengine/queryset/transform.py", line 63, in query raise InvalidQueryError(e) mongoengine.errors.InvalidQueryError: Cannot resolve field "email"

duaneking commented 5 years ago

Because MongoDB is not a true database - its just a serialized key-value store (often mistakenly called a document database, even if that's technically incorrect) - and is not ACID complaint like a database must be - since MongoDB is queue-to-write - Mongo DB is a cancer and shouldn't be used anyway, so its not a surprise that its not fully supported.