diff --git a/endpoints/web.py b/endpoints/web.py index a44c2da11..604255f36 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -128,22 +128,22 @@ def github_oauth_callback(): to_login = model.verify_federated_login('github', github_id) if not to_login: # try to create the user - try: to_login = model.create_federated_user(username, found_email, 'github', github_id) + + # Success, tell mixpanel + mixpanel.track(to_login.username, 'register', {'service': 'github'}) + + state = request.args.get('state', None) + if state: + logger.debug('Aliasing with state: %s' % state) + mixpanel.alias(to_login.username, state) + except model.DataModelException, ex: return render_template('githuberror.html', error_message=ex.message) if common_login(to_login): - # Success - mixpanel.track(to_login.username, 'register', {'service': 'github'}) - - state = request.args.get('state', None) - if state: - logger.debug('Aliasing with state: %s' % state) - mixpanel.alias(to_login.username, state) - return redirect(url_for('index')) # TODO something bad happened, we need to tell the user somehow