-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |