Example #1
0
def register(request):
    """The registration view.

    Note that usernames will always be lowercased. Email domains are lowercased while
    the first part remains case-sensitive.
    """
    if 'pass_auth' not in request.template_env.globals:
        redirect_name = hook_handle('auth_no_pass_redirect')
        if redirect_name:
            return redirect(
                request,
                'mediagoblin.plugins.{0}.register'.format(redirect_name))
        else:
            return redirect(request, 'index')

    register_form = hook_handle("auth_get_registration_form", request)

    if request.method == 'POST' and register_form.validate():
        # TODO: Make sure the user doesn't exist already
        user = register_user(request, register_form)

        if user:
            # redirect the user to their homepage... there will be a
            # message waiting for them to verify their email
            return redirect(request,
                            'mediagoblin.user_pages.user_home',
                            user=user.username)

    return render_to_response(
        request, 'mediagoblin/auth/register.html', {
            'register_form': register_form,
            'post_url': request.urlgen('mediagoblin.auth.register')
        })
Example #2
0
def register(request):
    """OpenID Registration View"""
    if request.method == 'GET':
        # Need to connect to openid provider before registering a user to
        # get the users openid url. If method is 'GET', then this page was
        # acessed without logging in first.
        return redirect(request, 'mediagoblin.plugins.openid.login')

    register_form = auth_forms.RegistrationForm(request.form)

    if register_form.validate():
        user = register_user(request, register_form)

        if user:
            # redirect the user to their homepage... there will be a
            # message waiting for them to verify their email
            return redirect(
                request, 'mediagoblin.user_pages.user_home',
                user=user.username)

    return render_to_response(
        request,
        'mediagoblin/auth/register.html',
        {'register_form': register_form,
         'post_url': request.urlgen('mediagoblin.plugins.openid.register')})
Example #3
0
def register(request):
    """OpenID Registration View"""
    if request.method == 'GET':
        # Need to connect to openid provider before registering a user to
        # get the users openid url. If method is 'GET', then this page was
        # acessed without logging in first.
        return redirect(request, 'mediagoblin.plugins.openid.login')

    register_form = auth_forms.RegistrationForm(request.form)

    if register_form.validate():
        user = register_user(request, register_form)

        if user:
            # redirect the user to their homepage... there will be a
            # message waiting for them to verify their email
            return redirect(request,
                            'mediagoblin.user_pages.user_home',
                            user=user.username)

    return render_to_response(
        request, 'mediagoblin/auth/register.html', {
            'register_form': register_form,
            'post_url': request.urlgen('mediagoblin.plugins.openid.register')
        })
Example #4
0
def register(request):
    """The registration view.

    Note that usernames will always be lowercased. Email domains are lowercased while
    the first part remains case-sensitive.
    """
    if 'pass_auth' not in request.template_env.globals:
        redirect_name = hook_handle('auth_no_pass_redirect')
        if redirect_name:
            return redirect(request, 'mediagoblin.plugins.{0}.register'.format(
                redirect_name))
        else:
            return redirect(request, 'index')

    register_form = hook_handle("auth_get_registration_form", request)

    if request.method == 'POST' and register_form.validate():
        # TODO: Make sure the user doesn't exist already
        user = register_user(request, register_form)

        if user:
            # redirect the user to their homepage... there will be a
            # message waiting for them to verify their email
            return redirect(
                request, 'mediagoblin.user_pages.user_home',
                user=user.username)

    return render_to_response(
        request,
        'mediagoblin/auth/register.html',
        {'register_form': register_form,
         'post_url': request.urlgen('mediagoblin.auth.register')})
def register(request):
#    if request.method == 'GET':
#        return redirect(
#            request,
#            'mediagoblin.plugins.recaptcha.register')

    register_form = auth_forms.RegistrationForm(request.form)
    config = pluginapi.get_config('mediagoblin.plugins.recaptcha')

    recaptcha_protocol = ''
    if config['RECAPTCHA_USE_SSL']:
        recaptcha_protocol = 'https'
    else:
        recaptcha_protocol = 'http'
    _log.debug("Connecting to reCAPTCHA service via %r", recaptcha_protocol)

    if register_form.validate():
        recaptcha_challenge = request.form['recaptcha_challenge_field']
        recaptcha_response = request.form['recaptcha_response_field']
        _log.debug("response field is: %r", recaptcha_response)
        _log.debug("challenge field is: %r", recaptcha_challenge)
        response = captcha.submit(
            recaptcha_challenge,
            recaptcha_response,
            config.get('RECAPTCHA_PRIVATE_KEY'),
            request.remote_addr,
            )

        goblin = response.is_valid
        if response.error_code:
            _log.warning("reCAPTCHA error: %r", response.error_code)

        if goblin:
            user = register_user(request, register_form)

            if user:
                # redirect the user to their homepage... there will be a
                # message waiting for them to verify their email
                return redirect(
                    request, 'mediagoblin.user_pages.user_home',
                    user=user.username)

        else:
            messages.add_message(
                request,
                messages.WARNING,
                _('Sorry, captcha was incorrect. Please try again.'))

    return render_to_response(
        request,
        'mediagoblin/plugins/recaptcha/register.html',
        {'register_form': register_form,
         'post_url': request.urlgen('mediagoblin.plugins.recaptcha.register'),
         'recaptcha_public_key': config.get('RECAPTCHA_PUBLIC_KEY'),
         'recaptcha_protocol' : recaptcha_protocol})
Example #6
0
def register(request):
    if request.method == 'GET':
        return redirect(request, 'mediagoblin.plugins.ldap.login')

    register_form = forms.RegisterForm(request.form)

    if register_form.validate():
        user = register_user(request, register_form)

        if user:
            # redirect the user to their homepage... there will be a
            # message waiting for them to verify their email
            return redirect(request,
                            'mediagoblin.user_pages.user_home',
                            user=user.username)

    return render_to_response(
        request, 'mediagoblin/auth/register.html', {
            'register_form': register_form,
            'post_url': request.urlgen('mediagoblin.plugins.ldap.register')
        })
Example #7
0
def register(request):
    if request.method == 'GET':
        return redirect(
            request,
            'mediagoblin.plugins.ldap.login')

    register_form = forms.RegisterForm(request.form)

    if register_form.validate():
        user = register_user(request, register_form)

        if user:
            # redirect the user to their homepage... there will be a
            # message waiting for them to verify their email
            return redirect(
                request, 'mediagoblin.user_pages.user_home',
                user=user.username)

    return render_to_response(
        request,
        'mediagoblin/auth/register.html',
        {'register_form': register_form,
         'post_url': request.urlgen('mediagoblin.plugins.ldap.register')})