Exemplo n.º 1
0
def send_confirmation_and_redirect(request, email, task):
    email_activation_key = utils.make_email_hash(email, task)
    phone_activation_code = utils.make_verify_phone_code()
    u = utils.create_user(
                    name=request.POST.get('name'), 
                    password=request.POST.get('password'), 
                    email=request.POST.get('email'), 
                    phone_number=request.POST.get('phone_number'), 
                    phone_activation_code=phone_activation_code, 
                    email_activation_key=email_activation_key)
    u.save()
    utils.send_verification_email(email, task)
    return http.HttpResponseRedirect('/account/email-sent/')
Exemplo n.º 2
0
def confirm_request_hash(request, task):
    if request.method == 'GET':
        d = request.GET
    elif request.method == 'POST':
        d = request.POST
    else:
        raise http.Http404('Invalid method')
    
    # Verify the hash.
    try:
        email, email_hash = d['e'], d['h']
        if email_hash != utils.make_email_hash(email, task):
            raise KeyError
    except KeyError:
        form_link = {utils.CREATE_TASK: '/accounts/register/', 
                     utils.RESET_TASK: '/accounts/password-change/'}[task]
        response = http.HttpResponseNotFound(
                            render_to_string('accounts/hash_error.html', 
                                             {'form_link': form_link}))