fix "next" behavior, poor sign-up/pledge flow [#40841931]

Sign In lightbox had broken cookie pusher on reg/auth pages.
Many holes had developed that broke return-to-page-after-auth (for
example, sign-in from pledge page).
Sporadic encoding issues.
pull/1/head
eric 2013-03-08 02:43:11 -05:00
parent 90d15b5c9b
commit 62627a80cf
14 changed files with 35 additions and 18 deletions

View File

@ -10,7 +10,7 @@
{% if user.is_authenticated %}
<p> Welcome {{user.username}}. Your API key is <span style="font-weight:bold">{{api_key}}</span>.</p>
{% else %}
<p> Please <a href="{% url superlogin %}?next={% firstof request.path '/' %}"><span>sign in</span></a> first.</p>
<p> Please <a href="{% url superlogin %}?next={% firstof request.get_full_path|urlencode '/' %}"><span>sign in</span></a> first.</p>
{% endif %}
<h3>Basic API info</h3>

View File

@ -2,7 +2,7 @@
<div class="right_border"><a href="{% url faq_location 'rightsholders' %}">Read the FAQ for authors and publishers</a></div>
<div class="right_border"><a href="{% url press %}">Our press coverage</a></div>
{% if not user.is_authenticated %}
<div class="signuptoday"><a href="{% url registration_register %}">Sign up today</a></div>
<div class="signuptoday"><a href="{% url registration_register %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Sign up today</a></div>
{% else %}
<div class="signuptoday"><a href="{% url campaign_list 'ending' %}">Our campaigns</a></div>
{% endif %}

View File

@ -24,7 +24,7 @@
{% block base_js %}
<script type="text/javascript" src="{{ jquery_home }}"></script>
{% endblock %}
<script type="text/javascript" src="/static/js/hijax.js?v=2"></script>
<script type="text/javascript" src="/static/js/hijax.js?v=3a"></script>
{% block extra_js %}
{% endblock %}
<script type="text/javascript" src="/static/js/watermark_init.js"></script>
@ -58,7 +58,6 @@
</head>
<body>
<div id="feedback">
<p><a href="/feedback/?page={{request.build_absolute_uri|urlencode:""}}" class="nounderline">Feedback</a></p>
</div>
@ -124,13 +123,13 @@
{% else %}
<div class="js-topmenu">
<ul class="menu">
<li><a href="{% url superlogin %}?next={% firstof request.path '/' %}" class="hijax"><span>Sign In</span></a></li>
<li><a href="{% url superlogin %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}" class="hijax"><span>Sign In</span></a></li>
{% if not suppress_search_box %}
{% ifnotequal request.get_full_path "/accounts/register/" %}
{% comment %}
don't display this on landing page where it's superseded by big signup box in splash area
{% endcomment %}
<li id="expander" class="last"><a href="{% url registration_register %}"><span>Sign Up</span></a></li>
<li id="expander" class="last"><a href="{% url registration_register %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}"><span>Sign Up</span></a></li>
{% endifnotequal %}
{% endif %}
</ul>

View File

@ -11,7 +11,7 @@
<div class="tabs-content" id="js-maincol">
{% if request.user.is_anonymous %}
<p>You must be <a href="{% url superlogin %}?next={{ request.path }}">logged in</a> to comment.</p>
<p>You must be <a href="{% url superlogin %}?next={{ request.get_full_path|urlencode }}">logged in</a> to comment.</p>
{% else %}
<form action="{% comment_form_target %}" method="post">{% csrf_token %}
{% if next %}<div><input type="hidden" name="next" value="{{ next }}" /></div>{% endif %}

View File

@ -22,7 +22,7 @@
<a href="https://www.facebook.com/sharer.php?u=https://{{ site.domain }}{% url work work.id|urlencode:"" %}"><li class="facebook first"><span>Facebook</span></li></a>
<a href="https://twitter.com/intent/tweet?url={{request.build_absolute_uri|urlencode:"" }}&amp;text=I%27m%20enjoying%20{{ work.title|urlencode }}%2C%20a%20free%2C%20non%2DDRM%20ebook%2E%20You%20can%20too%21"><li class="twitter"><span>Twitter</span></li></a>
{% endwith %}
<a href="{% url emailshare '' %}?next={% url work work.id|urlencode:"" %}"><li class="email"><span>Email</span></li></a>
<a href="{% url emailshare '' %}?next={% url work work.id %}"><li class="email"><span>Email</span></li></a>
<a href="#" id="embed2"><li class="embed"><span>Embed</span></li></a>
<div id="widgetcode2">Copy/paste this into your site:<br /><textarea rows="7" cols="22">&lt;iframe src="https://{{ request.META.HTTP_HOST }}/api/widget/{{ work.first_isbn_13 }}/" width="152" height="325" frameborder="0"&gt;&lt;/iframe&gt;</textarea></div>
</ul>

View File

@ -119,7 +119,7 @@ $j(document).ready(function() {
</form>
</div>
<br />
<p>Want to use a different card? You can change your credit card info on your <a href="{% url manage_account %}?next={{ request.path }}#your_payment_info">Account &amp; Pledges page</a>.
<p>Want to use a different card? You can change your credit card info on your <a href="{% url manage_account %}?next={{ request.get_full_path|urlencode }}#your_payment_info">Account &amp; Pledges page</a>.
</p>
{% else %}
<div id="authorize" {% if nonprofit.is_on %}class="off clearfix"{% else %}class="clearfix"{% endif %}>

View File

@ -68,7 +68,7 @@
</div>
</form>
<div class="google_signup">
<a href="/socialauth/login/google?next={{request.build_absolute_uri}}"><img src="{{ STATIC_URL }}images/auth/google_32_noborder.png" alt="google" /></a><div>Or: <a href="/socialauth/login/google?next={{request.build_absolute_uri}}">Sign Up With Google</a></div>
<a href="/socialauth/login/google?next=/next/"><img src="{{ STATIC_URL }}images/auth/google_32_noborder.png" alt="google" /></a><div>Or: <a href="/socialauth/login/google?next=/next/">Sign Up With Google</a></div>
</div>
{% else %}
<div>
@ -143,7 +143,7 @@
<input type="submit" class="signup" value="sign up" />
</div>
<div class="google_signup">
<a href="/socialauth/login/google?next={{request.build_absolute_uri}}"><img src="{{ STATIC_URL }}images/auth/google_32_noborder.png" alt="google" /></a><div><a href="/socialauth/login/google?next={{request.build_absolute_uri}}">Sign Up With Google</a></div>
<a href="/socialauth/login/google?next=/next/"><img src="{{ STATIC_URL }}images/auth/google_32_noborder.png" alt="google" /></a><div><a href="/socialauth/login/google?next=/next/">Sign Up With Google</a></div>
</div>
</form>
</div>

View File

@ -27,8 +27,8 @@
<p><strong>We need your help, though.</strong> We can't unglue ebooks all by ourselves; we need lots of people to pitch in. If you'd like to share free, unlimited, no-DRM, privacy-respecting ebooks with your patrons, here are some ways you can help:</p>
<dl>
<dt><a href="{% url registration_register %}">Sign up.</a></dt>
<dd>Starting an account, for yourself or your library, is free, and lets you add books to your wishlist, comment on them, and support campaigns. <a href="{% url registration_register %}">Sign up here.</a></dd>
<dt><a href="{% url registration_register %}?next={% request.get_full_path|urlencode }}">Sign up.</a></dt>
<dd>Starting an account, for yourself or your library, is free, and lets you add books to your wishlist, comment on them, and support campaigns. <a href="{{ request.get_full_path|urlencode}}">Sign up here.</a></dd>
<dt>Stay in touch.</dt>
<dd>You can follow us on Twitter (<a href="http://twitter.com/unglueit">@unglueit</a>), <a href="http://facebook/com/unglueit">Facebook</a>, and our <a href="http://blog.unglue.it">blog</a>, and <a href="http://eepurl.com/fKLfI">subscribe to our newsletter</a> (1-2 emails per month).</dd>
<dt>Add unglued ebooks to your collection.</dt>

View File

@ -15,7 +15,7 @@ Make sure the username box has your <b>username, not your email</b> -- some brow
<br />
<a href="{% url auth_password_reset %}">Forgot</a> your password? <a href="{% url registration_register %}">Need an account</a>? <a href="/faq/basics/account">Other questions</a>?
<a href="{% url auth_password_reset %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Forgot</a> your password? <a href="{% url registration_register %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Need an account</a>? <a href="/faq/basics/account">Other questions</a>?
<br /><br />

View File

@ -18,7 +18,7 @@
{% endifequal %}
{% else %}
<div>You must be logged in to change your password.</div>
<a href="{% url superlogin %}?next={% firstof request.path '/' %}" class="nounderline"><div class="actionbutton">Log in</div></a>
<a href="{% url superlogin %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}/next/{% endif %}" class="nounderline"><div class="actionbutton">Log in</div></a>
{% endif %}
<p>Want to <a href="{% url regluit.frontend.views.edit_user %}">change your username</a> instead?</p>

View File

@ -3,7 +3,15 @@
{% block doccontent %}
{% if not user.is_authenticated %}
<p>
An account activation email has been sent. Please check your email and click on the link to activate your account. We're also sending you an invitation to our email newsletter. It comes out about twice a month. Put "gluenews@gluejar.com" in your contact list to make sure you get it.
</p>
{% if request.COOKIES.next %}
<p>
You can also go back to <a href="{{ request.COOKIES.next }}">the page where you were</a>.
</p>
{% endif %}
{% else %}
<div>
You are logged in as <a href="{% url supporter supporter_username=request.user.username %}">{{ request.user.username }}</a>.

View File

@ -15,7 +15,7 @@
<div>
<div class="google_signup">
<h3>Or use an account you already have:</h3>
<a href="/socialauth/login/google?next=/"><img src="{{ STATIC_URL }}images/auth/google_32_noborder.png"><div>Sign in with Google</div></a>
<a href="/socialauth/login/google?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}/next/{% endif %}"><img src="{{ STATIC_URL }}images/auth/google_32_noborder.png"><div>Sign in with Google</div></a>
</div>
{% else %}
<div>

View File

@ -264,7 +264,7 @@ $j(document).ready(function(){
{% if user.is_authenticated %}
{% render_comment_form for work %}
{% else %}
<p>You must be <a href="{% url superlogin %}?next={{ request.path }}">logged in</a> to comment.</p>
<p>You must be <a href="{% url superlogin %}?next={{ request.get_full_path|urlencode }}">logged in</a> to comment.</p>
{% endif %}
</div>
</div>

View File

@ -23,6 +23,16 @@ $j(document).ready(function() {
jQuery.getScript('https://platform.readmill.com/send.js');
}
//need to push next cookie for sign-in links
var vars = $j(this).attr("href").split("next=");
if (vars.length>1){
next=vars[1];
if(next!='') {
next = next.replace(/[\x22\x27\x3c\x3e]/g,'');
$j.cookie('next', next, {path: '/'});
}
}
// fade-out rest of page elements on expand
$j('#feedback, #js-page-wrap, #footer').css({"opacity": "0.07"});
$j('#about_expandable').css({'position': 'absolute'});