diff --git a/hc/accounts/backends.py b/hc/accounts/backends.py index d21780b1..b0ba119d 100644 --- a/hc/accounts/backends.py +++ b/hc/accounts/backends.py @@ -17,8 +17,8 @@ class ProfileBackend(BasicBackend): def authenticate(self, username=None, token=None): try: - profile = (Profile.objects - .select_related("user").get(user__username=username)) + profiles = Profile.objects.select_related("user") + profile = profiles.get(user__username=username) except Profile.DoesNotExist: return None @@ -27,9 +27,6 @@ class ProfileBackend(BasicBackend): return profile.user - def get_user(self, user_id): - return User.objects.filter(pk=user_id).first() - class EmailBackend(BasicBackend): diff --git a/hc/accounts/views.py b/hc/accounts/views.py index befeb44c..cb9368c2 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -59,7 +59,7 @@ def _associate_demo_check(request, user): del request.session["welcome_code"] -def login(request): +def login(request, show_password=False): bad_credentials = False if request.method == 'POST': form = EmailPasswordForm(request.POST) @@ -72,6 +72,7 @@ def login(request): auth_login(request, user) return redirect("hc-checks") bad_credentials = True + show_password = True else: try: user = User.objects.get(email=email) @@ -89,7 +90,8 @@ def login(request): ctx = { "form": form, "bad_credentials": bad_credentials, - "bad_link": bad_link + "bad_link": bad_link, + "show_password": show_password } return render(request, "accounts/login.html", ctx) diff --git a/hc/urls.py b/hc/urls.py index 12c23c67..5b9b7d4e 100644 --- a/hc/urls.py +++ b/hc/urls.py @@ -1,7 +1,10 @@ from django.conf.urls import include, url from django.contrib import admin +from hc.accounts.views import login as hc_login + urlpatterns = [ + url(r'^admin/login/', hc_login, {"show_password": True}), url(r'^admin/', include(admin.site.urls)), url(r'^accounts/', include('hc.accounts.urls')), url(r'^', include('hc.api.urls')), diff --git a/templates/accounts/login.html b/templates/accounts/login.html index a38a9eed..03a70c67 100644 --- a/templates/accounts/login.html +++ b/templates/accounts/login.html @@ -15,8 +15,12 @@
+ {% if show_password %} + Please entery your email address and password. + {% else %} Please enter your email address. Next, we'll send you an email with log-in instructions! + {% endif %}