superlogin- failed logins check for socialauth and if so, as user to use it
superlogin injects extra_context into regular login methodpull/1/head
parent
14174ecb17
commit
80536a491a
|
@ -1133,6 +1133,14 @@ class UserProfile(models.Model):
|
|||
logger.error("error unsubscribing from mailchimp list %s" % (e))
|
||||
return False
|
||||
|
||||
@property
|
||||
def social_auths(self):
|
||||
socials= self.user.social_auth.all()
|
||||
auths={}
|
||||
for social in socials:
|
||||
auths[social.provider]=True
|
||||
return auths
|
||||
|
||||
#class CampaignSurveyResponse(models.Model):
|
||||
# # generic
|
||||
# campaign = models.ForeignKey("Campaign", related_name="surveyresponse", null=False)
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
{% block doccontent %}
|
||||
<div id="lightbox_content">
|
||||
{% if form.errors %}
|
||||
<p class="errorlist">Your username and password didn't match. Please try again.</p>
|
||||
{% for error in form.non_field_errors %}
|
||||
<p class="errorlist">{{ error }}</p>
|
||||
{% endfor %}
|
||||
Make sure the username box has your <b>username, not your email</b> -- some browsers automatically fill in your email. We're working on fixing this bug.
|
||||
{% endif %}
|
||||
{% if not user.is_authenticated %}
|
||||
|
@ -18,7 +20,10 @@ Make sure the username box has your <b>username, not your email</b> -- some brow
|
|||
|
||||
<br /><br />
|
||||
<div class="google_signup">
|
||||
<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 in with Google</a></div>
|
||||
<div {% if socials.google %}class="errorlist"{% endif %}>
|
||||
<div><a href="/socialauth/login/google?next=/next/"><img src="{{ STATIC_URL }}images/auth/google_32_noborder.png" alt="google" /></a></div>
|
||||
<div>Or: <a href="/socialauth/login/google?next=/next/">Sign in with Google</a></div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div>
|
||||
|
|
|
@ -20,6 +20,7 @@ urlpatterns = patterns(
|
|||
url(r"^next/$", "next", name="next"),
|
||||
url(r"^supporter/(?P<supporter_username>[^/]+)/$", "supporter", {'template_name': 'supporter.html'}, name="supporter"),
|
||||
url(r"^accounts/manage/$", login_required(ManageAccount.as_view()), name="manage_account"),
|
||||
url(r'^accounts/superlogin/$', 'superlogin', name='superlogin'),
|
||||
url(r"^search/$", "search", name="search"),
|
||||
url(r"^privacy/$", TemplateView.as_view(template_name="privacy.html"),
|
||||
name="privacy"),
|
||||
|
|
|
@ -22,6 +22,7 @@ from django.core.urlresolvers import reverse
|
|||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.views import login
|
||||
from django.contrib.comments import Comment
|
||||
from django.contrib.sites.models import Site
|
||||
from django.db.models import Q, Count, Sum
|
||||
|
@ -133,6 +134,17 @@ def stub(request):
|
|||
def acks(request, work):
|
||||
return render(request,'front_matter.html', {'campaign': work.last_campaign()})
|
||||
|
||||
def superlogin(request, **kwargs):
|
||||
extra_context = None
|
||||
if request.method == 'POST' and request.user.is_anonymous():
|
||||
username=request.POST.get("username", "")
|
||||
try:
|
||||
user=models.User.objects.get(username=username)
|
||||
extra_context={"socials":user.profile.social_auths}
|
||||
except:
|
||||
pass
|
||||
return login(request, extra_context=extra_context)
|
||||
|
||||
def work(request, work_id, action='display'):
|
||||
work = safe_get_work(work_id)
|
||||
if action == "acks":
|
||||
|
@ -1506,7 +1518,7 @@ def supporter(request, supporter_username, template_name):
|
|||
|
||||
def edit_user(request):
|
||||
if not request.user.is_authenticated():
|
||||
return HttpResponseRedirect(reverse('auth_login'))
|
||||
return HttpResponseRedirect(reverse('superlogin'))
|
||||
form=UserData()
|
||||
emailform = UserEmail()
|
||||
if request.method == 'POST':
|
||||
|
|
|
@ -104,6 +104,7 @@
|
|||
float: left;
|
||||
padding-left: 5px;
|
||||
font-size: 15px;
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
img {
|
||||
|
|
Loading…
Reference in New Issue