Send a registration even for github created users. Alias their new username to their old mixpanel ID passed in the OAuth state parameter.

This commit is contained in:
yackob03 2013-10-10 17:32:32 -04:00
parent b9a5060882
commit 32b28df2d2
4 changed files with 40 additions and 3 deletions

View file

@ -7,7 +7,7 @@ from flask.ext.login import login_user, UserMixin, login_required, logout_user
from flask.ext.principal import identity_changed, Identity, AnonymousIdentity
from data import model
from app import app, login_manager
from app import app, login_manager, mixpanel
logger = logging.getLogger(__name__)
@ -143,6 +143,14 @@ def github_oauth_callback():
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