Switching login form's form handling to NewsBlur form (from django form).

This commit is contained in:
Samuel Clay 2014-04-29 15:24:33 -07:00
parent 9173bee736
commit dc7cab36a4
5 changed files with 30 additions and 9 deletions

View file

@ -19,7 +19,7 @@ from apps.profile.models import Profile, PaymentHistory, RNewUserQueue
from apps.reader.models import UserSubscription, UserSubscriptionFolders, RUserStory
from apps.profile.forms import StripePlusPaymentForm, PLANS, DeleteAccountForm
from apps.profile.forms import ForgotPasswordForm, ForgotPasswordReturnForm, AccountSettingsForm
from apps.reader.forms import SignupForm
from apps.reader.forms import SignupForm, LoginForm
from apps.social.models import MSocialServices, MActivity, MSocialProfile
from utils import json_functions as json
from utils.user_functions import ajax_login_required
@ -81,6 +81,22 @@ def get_preference(request):
response = dict(code=code, payload=payload)
return response
@csrf_protect
def login(request):
form = LoginForm()
if request.method == "POST":
form = LoginForm(data=request.POST)
if form.is_valid():
login_user(request, form.get_user())
logging.user(form.get_user(), "~FG~BBOAuth Login~FW")
return HttpResponseRedirect(request.POST['next'] or reverse('index'))
return render_to_response('accounts/login.html', {
'form': form,
'next': request.REQUEST.get('next', "")
}, context_instance=RequestContext(request))
@csrf_protect
def signup(request):
form = SignupForm()
@ -92,7 +108,7 @@ def signup(request):
login_user(request, new_user)
logging.user(new_user, "~FG~SB~BBNEW SIGNUP~FW")
new_user.profile.activate_free()
return HttpResponseRedirect(request.POST['next'])
return HttpResponseRedirect(request.POST['next'] or reverse('index'))
return render_to_response('accounts/signup.html', {
'form': form,

View file

@ -52,7 +52,7 @@ class LoginForm(forms.Form):
self.user_cache = authenticate(username=email_user.username, password=email_user.username)
if self.user_cache is None:
logging.info(" ***> [%s] Bad Login" % username)
raise forms.ValidationError(_("Whoopsy-daisy. Try again."))
raise forms.ValidationError(_("Whoopsy-daisy, wrong password. Try again."))
elif username and not user:
raise forms.ValidationError(_("That username is not registered. Please try again."))

View file

@ -10662,6 +10662,9 @@ form.opml_import_form input {
height: 34px;
font-size: 22px;
}
.NB-static-oauth .NB-static-form-username-label label {
padding-top: 0;
}
.NB-static-oauth input[type=submit].NB-static-form-submit {
margin: 24px 0 0 0;

View file

@ -23,15 +23,19 @@
</div>
<div class="NB-static-form-wrapper" style="overflow:hidden">
<form method="post" class="NB-static-form" action="{% url 'django.contrib.auth.views.login' %}">
<form method="post" class="NB-static-form" action="{% url 'login' %}">
{% if form.errors %}
<p class="NB-error error">Your username and password didn't match.<br />Please try again.</p>
<p class="NB-error error">
{% for field, error in form.errors.items %}
{{ error.as_text|cut:"* " }}
<br />
{% endfor %}</p>
{% else %}{% if next %}
<p class="NB-error error">Please login to continue.</p>
{% endif %}{% endif %}
{% csrf_token %}
<div class="NB-static-form-label">{{ form.username.label_tag }}</div>
<div class="NB-static-form-label NB-static-form-username-label">{{ form.username.label_tag }}</div>
<div class="NB-static-form-input">{{ form.username }}</div>
<div class="NB-static-form-label">{{ form.password.label_tag }}</div>
<div class="NB-static-form-input">{{ form.password }}</div>

View file

@ -51,9 +51,7 @@ urlpatterns = patterns('',
url(r'^android/?', static_views.android, name='android-static'),
url(r'^firefox/?', static_views.firefox, name='firefox'),
url(r'zebra/', include('zebra.urls', namespace="zebra", app_name='zebra')),
url(r'^account/login/?$',
'django.contrib.auth.views.login',
{'template_name': 'accounts/login.html'}, name='login'),
url(r'^account/login/?$', profile_views.login, name='login'),
url(r'^account/signup/?$', profile_views.signup, name='signup'),
url(r'^account/logout/?$',
'django.contrib.auth.views.logout',