diff --git a/allauth_ens/templates/allauth_ens/simple_message.html b/allauth_ens/templates/allauth_ens/simple_message.html
new file mode 100644
index 0000000..2cb2d40
--- /dev/null
+++ b/allauth_ens/templates/allauth_ens/simple_message.html
@@ -0,0 +1,32 @@
+{% load i18n static %}
+{% load account allauth_ens %}
+
+
+
+
+
+ Error{% if request.site.name %} ยท {{ request.site.name }}{% endif %}
+
+
+
+
+
+
+ {{ message }}
+
+
+
diff --git a/allauth_ens/views.py b/allauth_ens/views.py
index ea1a343..83036b7 100644
--- a/allauth_ens/views.py
+++ b/allauth_ens/views.py
@@ -1,5 +1,8 @@
import django
from django.views.generic import RedirectView
+from django.contrib import admin
+from django.shortcuts import render
+
if django.VERSION >= (1, 10):
from django.urls import reverse_lazy
@@ -23,3 +26,20 @@ class CaptureLogout(RedirectView):
capture_logout = CaptureLogout.as_view()
+
+
+def capture_login_admin(request):
+ """ Redirect the user to allauth login page if they are not logged in, or
+ fails and display a message if they are logged in *but* are not
+ administrators """
+
+ if admin.site.has_permission(request):
+ return capture_login(request)
+
+ context = {
+ 'message': ("The account you're authenticated with is not an "
+ "administrator account."),
+ }
+ return render(request,
+ "allauth_ens/simple_message.html",
+ context=context)