intent/intent/accounts/adapter.py

14 lines
584 B
Python
Raw Normal View History

from allauth.account.adapter import DefaultAccountAdapter
from django.contrib import messages
from django.shortcuts import redirect
class AccountAdapter(DefaultAccountAdapter):
def pre_login(self, request, user, **kwargs):
# Sysadmins are separate from regular users and cannot act within projects,
# so they only sign in through the admin site.
if user.is_staff:
messages.error(request, "Administrator accounts sign in at the admin site.")
return redirect("admin:login")
return super().pre_login(request, user, **kwargs)