From 5d066db1bfd7a6f10cb7514501abb9c16440b47d Mon Sep 17 00:00:00 2001 From: Carson Gee Date: Mon, 30 Sep 2013 21:31:29 -0400 Subject: [PATCH] Add feature to do auto signup with external auth This adds a feature flag: AUTH_USE_MIT_CERTIFICATES_IMMEDIATE_SIGNUP that does an automatic signup of users if they are using external authentcation. --- common/djangoapps/external_auth/views.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/djangoapps/external_auth/views.py b/common/djangoapps/external_auth/views.py index 5872955780..2583b7bd20 100644 --- a/common/djangoapps/external_auth/views.py +++ b/common/djangoapps/external_auth/views.py @@ -250,6 +250,19 @@ def _signup(request, eamap): # save this for use by student.views.create_account request.session['ExternalAuthMap'] = eamap + if settings.MITX_FEATURES.get('AUTH_USE_MIT_CERTIFICATES_IMMEDIATE_SIGNUP',''): + # do signin immediately, by calling create_account, instead of asking + # student to fill in form. MIT students already have information filed. + username = eamap.external_email.split('@',1)[0] + username = username.replace('.','_') + post_vars = dict(username = username, + honor_code = u'true', + terms_of_service = u'true', + ) + log.info('doing immediate signup for %s, params=%s' % (username, post_vars)) + student.views.create_account(request, post_vars) + return redirect('/') + # default conjoin name, no spaces, flattened to ascii b/c django can't handle unicode usernames, sadly # but this only affects username, not fullname username = re.sub(r'\s', '', _flatten_to_ascii(eamap.external_name), flags=re.UNICODE)