Implement OTP and show received callbacks

This commit is contained in:
2022-10-15 21:51:47 +01:00
parent 8369f44bd4
commit 361b7b96f0
17 changed files with 396 additions and 155 deletions

View File

@@ -27,6 +27,9 @@ SECRET_KEY = getenv("SECRET_KEY", "")
STRIPE_ADMIN_COUPON = getenv("STRIPE_ADMIN_COUPON", "")
# Hook URL, do not include leading or trailing slash
HOOK_PATH = "hook"
DEBUG = getenv("DEBUG", "false").lower() in trues
PROFILER = getenv("PROFILER", "false").lower() in trues
@@ -39,4 +42,4 @@ if DEBUG:
"10.0.2.2",
]
SETTINGS_EXPORT = ["STRIPE_ENABLED"]
SETTINGS_EXPORT = ["STRIPE_ENABLED", "URL", "HOOK_PATH"]

View File

@@ -30,6 +30,7 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
"core",
"django.contrib.admin",
# 'core.apps.LibraryAdminConfig', # our custom OTP'ed admin
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
@@ -42,6 +43,10 @@ INSTALLED_APPS = [
"crispy_bulma",
# "django_tables2",
# "django_tables2_bulma_template",
"django_otp",
"django_otp.plugins.otp_totp",
# 'django_otp.plugins.otp_hotp',
# 'django_otp.plugins.otp_static',
]
CRISPY_TEMPLATE_PACK = "bulma"
CRISPY_ALLOWED_TEMPLATE_PACKS = (
@@ -57,6 +62,7 @@ MIDDLEWARE = [
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django_otp.middleware.OTPMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_htmx.middleware.HtmxMiddleware",

View File

@@ -16,11 +16,13 @@ Including another URLconf
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth.views import LoginView
from django.urls import include, path
from django.views.generic import TemplateView
from django_otp.forms import OTPAuthenticationForm
from core.views import base, hooks
from core.views.callbacks import Callback
from core.views import base, callbacks, hooks
from core.views.stripe_callbacks import Callback
urlpatterns = [
path("__debug__/", include("debug_toolbar.urls")),
@@ -38,7 +40,10 @@ urlpatterns = [
),
path("cancel/", TemplateView.as_view(template_name="cancel.html"), name="cancel"),
path("portal", base.Portal.as_view(), name="portal"),
path("admin/", admin.site.urls),
path("sapp/", admin.site.urls),
path(
"accounts/login/", LoginView.as_view(authentication_form=OTPAuthenticationForm)
),
path("accounts/", include("django.contrib.auth.urls")),
path("accounts/signup/", base.Signup.as_view(), name="signup"),
path("hooks/<str:type>/", hooks.Hooks.as_view(), name="hooks"),
@@ -48,6 +53,17 @@ urlpatterns = [
"hooks/page/del/<str:hook_id>/", hooks.HookAction.as_view(), name="hook_action"
),
path(
"hooks/page/edit/<str:hook_id>/", hooks.HookAction.as_view(), name="hook_action"
"hooks/modal/edit/<str:hook_id>/",
hooks.HookAction.as_view(),
name="hook_action",
),
path(
f"{settings.HOOK_PATH}/<str:hook_name>/", hooks.HookAPI.as_view(), name="hook"
),
path(
"callbacks/<str:type>/<str:hook_id>/",
callbacks.Callbacks.as_view(),
name="callbacks",
),
path("callbacks/<str:type>/", callbacks.Callbacks.as_view(), name="callbacks"),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)