From 346b594b66b41eef2880b582c4a130c4e80a217b Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 17 Oct 2014 11:44:31 -0400 Subject: [PATCH] Make the external login error messaging nicer when an email address conflict occurs --- endpoints/callbacks.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/endpoints/callbacks.py b/endpoints/callbacks.py index 637033ab6..95fdaa5d5 100644 --- a/endpoints/callbacks.py +++ b/endpoints/callbacks.py @@ -106,7 +106,15 @@ def conduct_oauth_login(service_name, user_id, username, email, metadata={}): logger.debug('Aliasing with state: %s' % state) analytics.alias(to_login.username, state) - except model.DataModelException, ex: + except model.InvalidEmailAddressException as ieex: + message = "The e-mail address %s is already associated " % (email, ) + message = message + "with an existing %s account." % (app.config['REGISTRY_TITLE_SHORT'], ) + message = message + "\nPlease log in with your username and password and " + message = message + "associate your %s account to use it in the future." % (service_name, ) + + return render_ologin_error(service_name, message) + + except model.DataModelException as ex: return render_ologin_error(service_name, ex.message) if common_login(to_login):