Exemple #1
0
def render_login(request,
                 user_creation_form,
                 login_form,
                 redirect_to,
                 email_form=None,
                 confirm_type=None):
    redirect_to = redirect_to or '/'
    context = {
        REDIRECT_FIELD_NAME: redirect_to,
        'app_id': settings.FACEBOOK_APP_ID,
    }
    if confirm_type is None:
        context['creation_form'] = user_creation_form
        context['login_form'] = login_form
        context['ted_auth'] = get_authentication_provider('ted')
        context['stanford_auth'] = get_authentication_provider('stanford')
        context['facebook_login_confirm'] = reverse(
            'thirdpartyaccounts:facebook_login_confirm')
        template = 'auth/login.html'
    else:
        if email_form:
            context['email_form'] = email_form
        template = 'auth/login_create.html'
        if confirm_type == 'ted':
            context['ted_auth'] = get_authentication_provider('ted')
        if confirm_type == 'stanford':
            context['stanford_auth'] = get_authentication_provider('stanford')
        if confirm_type == 'facebook':
            context['submit_facebook'] = "submit-proceed-to-create-facebook"
    return render_to_response(template,
                              context,
                              context_instance=RequestContext(request))
Exemple #2
0
def render_login(request,
                 user_creation_form,
                 login_form,
                 redirect_to,
                 email_form=None,
                 confirm_type=None):
    redirect_to = redirect_to or '/'
    context = {
        REDIRECT_FIELD_NAME: redirect_to,
    }
    if confirm_type is None:
        context['creation_form'] = user_creation_form
        context['login_form'] = login_form
        context['ted_auth'] = get_authentication_provider('ted')
        context['stanford_auth'] = get_authentication_provider('stanford')
        template = 'auth/login.html'
    else:
        if email_form:
            context['email_form'] = email_form
        template = 'auth/login_create.html'
        if confirm_type == 'ted':
            context['ted_auth'] = get_authentication_provider('ted')
        if confirm_type == 'stanford':
            context['stanford_auth'] = get_authentication_provider('stanford')
    return render_to_response(template,
                              context,
                              context_instance=RequestContext(request))
Exemple #3
0
def render_login(request, user_creation_form, login_form, redirect_to):
    redirect_to = redirect_to or '/'
    ted_auth = get_authentication_provider('ted')
    stanford_auth = get_authentication_provider('stanford')
    return render_to_response('auth/login.html', {
        'creation_form': user_creation_form,
        'login_form': login_form,
        'ted_auth': ted_auth,
        'stanford_auth': stanford_auth,
        REDIRECT_FIELD_NAME: redirect_to,
    },
                              context_instance=RequestContext(request))
Exemple #4
0
def confirm_create_user(request, account_type, email):
    redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME, '')
    if request.method == 'POST':
        form = EmailForm(request.POST)
        if form.is_valid():
            email = form.cleaned_data['email']
            if account_type == 'facebook':
                return facebook_login(request,
                                      next=redirect_to,
                                      confirmed=True,
                                      email=email)
            if account_type == 'google':
                return google_login(request,
                                    next=redirect_to,
                                    confirmed=True,
                                    email=email)
            if account_type == 'twitter':
                return twitter_login(request,
                                     next=redirect_to,
                                     confirmed=True,
                                     email=email)
            if account_type == 'openid':
                pass
            if account_type == 'ted':
                provider = get_authentication_provider('ted')
                return provider.view(request, confirmed=True, email=email)
            if account_type == 'udacity':
                request.session['openid_provider'] = 'Udacity'
                return begin_openid(
                    request,
                    user_url='https://www.udacity.com/openid/server',
                    redirect_to=reverse('socialauth_udacity_complete',
                                        args=(email, )),
                    confirmed=True)
    else:
        initial = {}
        if email:
            initial['email'] = email
        form = EmailForm(initial=initial)
    return render_login(request,
                        CustomUserCreationForm(label_suffix=""),
                        AuthenticationForm(label_suffix=""),
                        redirect_to,
                        email_form=form,
                        confirm_type=account_type)
Exemple #5
0
def confirm_create_user(request, account_type, email):
    redirect_to = post_or_get_value(request, REDIRECT_FIELD_NAME, '')
    if request.method == 'POST':
        form = EmailForm(request.POST)
        if form.is_valid():
            email = form.cleaned_data['email']
            if account_type == 'facebook':
                return facebook_login(request,
                                      next=redirect_to,
                                      confirmed=True,
                                      email=email,
                                      form_data=form.cleaned_data)
            if account_type == 'google':
                return google_login(request,
                                    next=redirect_to,
                                    confirmed=True,
                                    email=email)
            if account_type == 'twitter':
                return twitter_login(request,
                                     next=redirect_to,
                                     confirmed=True,
                                     email=email)
            if account_type == 'ted':
                provider = get_authentication_provider('ted')
                return provider.view(request, confirmed=True, email=email)
    else:
        initial = {}
        if email:
            initial['email'] = email
        openid_url = request.GET.get('openid_url', '')
        if openid_url:
            initial['url'] = openid_url
        form = EmailForm(initial=initial)
    return render_login(request,
                        CustomUserCreationForm(label_suffix=""),
                        AuthenticationForm(label_suffix=""),
                        redirect_to,
                        email_form=form,
                        confirm_type=account_type)