Skip to content

Commit

Permalink
change theme, add adapter for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Oct 22, 2024
1 parent d1c5a2a commit ef2a8c5
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
# https://django-allauth.readthedocs.io/en/latest/forms.html
ACCOUNT_FORMS = {"signup": "metadata_catalogue.users.forms.UserSignupForm"}

ALLAUTH_UI_THEME = "light"
ALLAUTH_UI_THEME = "nina"

if env("SOCIALACCOUNT_ADAPTER", default=None):
SOCIALACCOUNT_ADAPTER = env("SOCIALACCOUNT_ADAPTER")
Expand Down
2 changes: 2 additions & 0 deletions config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ def show_toolbar(request):


INSTALLED_APPS += ["models2puml"]

SOCIALACCOUNT_ADAPTER = "metadata_catalogue.users.adapters.SocialAccountAdapter"
8 changes: 8 additions & 0 deletions metadata_catalogue/templates/allauth/layouts/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'allauth/layouts/base.html' %}

{% load static tailwind_tags %}

{% block extra_head %}
<link rel="stylesheet" href="{% static 'allauth_ui/output.css' %}" />
{% tailwind_css %}
{% endblock extra_head %}
8 changes: 8 additions & 0 deletions metadata_catalogue/theme/forced_classes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file is used just to force the presence of certain tailwind classes...

FORCED_CLASSES = """
"bg-primary",
"bg-secondary",
btn
w-full my-1 text-primary-content bg-primary hover:bg-accent
"""
41 changes: 35 additions & 6 deletions metadata_catalogue/users/adapters.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
from __future__ import annotations

import typing
import logging
import traceback
from typing import Self

from allauth.account.adapter import DefaultAccountAdapter
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
from django.conf import settings
from django.http import HttpRequest

if typing.TYPE_CHECKING:
from metadata_catalogue.users.models import User

def report(e, error):
logging.error(str(e))
logging.error(str(error))
try:
from sentry_sdk import capture_exception, set_context

set_context("oauth error", {"error": str(error)})
capture_exception(e)
except Exception:
logging.error(traceback.format_exc())


class AccountAdapter(DefaultAccountAdapter):
def is_open_for_signup(self, request: HttpRequest) -> bool:
def is_open_for_signup(self: Self, request: HttpRequest) -> bool:
return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)


class SocialAccountAdapter(DefaultSocialAccountAdapter):
"""
just for debugging obscure integration exceptions
"""

def on_authentication_error(
self: Self, request, provider, error=None, exception=None, extra_context=None
):
print(error, exception)
report(exception, error)
return super().on_authentication_error(
request,
provider,
error=error,
exception=exception,
extra_context=extra_context,
)

0 comments on commit ef2a8c5

Please sign in to comment.