diff --git a/example/gae/auth/models.py b/example/gae/auth/models.py index beb8ad3..c7cab8f 100644 --- a/example/gae/auth/models.py +++ b/example/gae/auth/models.py @@ -99,12 +99,14 @@ def from_profile(cls, user, profile): if not user or user.is_anonymous(): email = profile.data.get("email") if not email: - logging.warning("Social connection could not provide email") - raise Exception(_("Social connection could not provide email")) + msg = "Cannot create new user, authentication provider did not not provide email" + logging.warning(msg) + raise Exception(_(msg)) conflict = User.query(User.email == email).get() if conflict: - msg = _("Cannot create new user, email {} is already used. Login and then connect external profile.") - raise Exception(msg.format(email)) + msg = _("Cannot create new user, email {} is already used. Login and then connect external profile.").format(email) + logging.warning(msg) + raise Exception(msg) now = datetime.now() user = User( diff --git a/example/gae/website/settings.py b/example/gae/website/settings.py index 48b7aa4..c0765e0 100644 --- a/example/gae/website/settings.py +++ b/example/gae/website/settings.py @@ -99,5 +99,6 @@ }, } +# Settings with secrets if PRODUCTION: from website.settings_prd import * diff --git a/example/sqla/auth/models.py b/example/sqla/auth/models.py index 50fb7e6..b8ceb39 100644 --- a/example/sqla/auth/models.py +++ b/example/sqla/auth/models.py @@ -67,6 +67,9 @@ def gravatar(self): encoded = hashlib.md5(email).hexdigest() return "https://secure.gravatar.com/avatar/%s.png" % encoded + def social_connections(self): + return SocialConnection.query.filter(SocialConnection.user_id == self.id).all() + # @login_manager.user_loader # def load_user(user_id): # return None #User.get(user_id) @@ -105,12 +108,14 @@ def from_profile(cls, user, profile): if not user or user.is_anonymous(): email = profile.data.get("email") if not email: - logging.warning("Social connection could not provide email") - raise Exception(_("Social connection could not provide email")) + msg = "Cannot create new user, authentication provider did not not provide email" + logging.warning(msg) + raise Exception(_(msg)) conflict = User.query.filter(User.email == email).first() if conflict: - msg = _("Cannot create new user, email {} is already used. Login and then connect external profile.") - raise Exception(msg.format(email)) + msg = _("Cannot create new user, email {} is already used. Login and then connect external profile.").format(email) + logging.warning(msg) + raise Exception(msg) now = datetime.now() user = User( diff --git a/example/sqla/auth/templates/User/profile.html b/example/sqla/auth/templates/User/profile.html index 4651988..1cb9bba 100644 --- a/example/sqla/auth/templates/User/profile.html +++ b/example/sqla/auth/templates/User/profile.html @@ -22,5 +22,34 @@