Skip to content

Commit

Permalink
Added auth to frontend (#76)
Browse files Browse the repository at this point in the history
* add dj-rest-auth

* Update frontend api

* Started using autogenerated api

* Moved auto api

* Remove duplicate auth routes

* Fixed schema for github login

* Improved user_supports field on bills

* Updated frontend api

* Added session auth through github to frontend

* Added back debug_toolbar profiling

* Minor cleanup
  • Loading branch information
mfosterw authored Mar 10, 2024
1 parent f5ab06d commit 8cec24c
Show file tree
Hide file tree
Showing 53 changed files with 2,535 additions and 888 deletions.
9 changes: 8 additions & 1 deletion config/api_router.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.conf import settings
from django.urls import include
from django.urls import path
from rest_framework.routers import DefaultRouter
from rest_framework.routers import SimpleRouter

from democrasite.users.api.views import GitHubLogin
from democrasite.users.api.views import UserViewSet
from democrasite.webiscite.api.views import BillViewSet

Expand All @@ -13,4 +16,8 @@
# Unfortunately if we want automatical links for models we can't use a namespace
# but I may reconsider anyway
# app_name = "api" # noqa: ERA001
urlpatterns = router.urls
urlpatterns = [
*router.urls,
path("auth/", include("dj_rest_auth.urls")),
path("auth/github/", GitHubLogin.as_view(), name="github_login"),
]
21 changes: 2 additions & 19 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
"rest_framework.authtoken",
"corsheaders",
"drf_spectacular",
"dj_rest_auth",
"dj_rest_auth.registration",
# Machina (forum) dependencies:
"mptt",
"haystack",
Expand Down Expand Up @@ -301,25 +303,6 @@
"root": {"level": "INFO", "handlers": ["console"]},
}

# django-debug-toolbar
# ------------------------------------------------------------------------------
# https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-panels
DEBUG_TOOLBAR_PANELS = [
"debug_toolbar.panels.history.HistoryPanel",
"debug_toolbar.panels.versions.VersionsPanel",
"debug_toolbar.panels.timer.TimerPanel",
"debug_toolbar.panels.settings.SettingsPanel",
"debug_toolbar.panels.headers.HeadersPanel",
"debug_toolbar.panels.request.RequestPanel",
"debug_toolbar.panels.sql.SQLPanel",
"debug_toolbar.panels.staticfiles.StaticFilesPanel",
"debug_toolbar.panels.templates.TemplatesPanel",
"debug_toolbar.panels.cache.CachePanel",
"debug_toolbar.panels.signals.SignalsPanel",
"debug_toolbar.panels.redirects.RedirectsPanel",
# 'debug_toolbar.panels.profiling.ProfilingPanel', causes errors with frontend
]


# Celery
# ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"] # noqa: S104
# Admin site is only enabled during development
INSTALLED_APPS += ["django.contrib.admin"] # type: ignore[used-before-def]
INSTALLED_APPS += ["django.contrib.admin"]

# CACHES
# ------------------------------------------------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from django.views.generic import TemplateView
from drf_spectacular.views import SpectacularAPIView
from drf_spectacular.views import SpectacularSwaggerView
from rest_framework.authtoken.views import obtain_auth_token

urlpatterns = [
path(
Expand All @@ -36,8 +35,6 @@
urlpatterns += [
# API base url
path("api/", include("config.api_router")),
# DRF auth token
path("auth-token/", obtain_auth_token),
path("api/schema/", SpectacularAPIView.as_view(), name="api-schema"),
path(
"api/docs/",
Expand Down
1 change: 0 additions & 1 deletion democrasite-frontend/.env.local

This file was deleted.

2 changes: 1 addition & 1 deletion democrasite-frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
# .env*.local # uncomment if sensitive environment variables added
.env*.local

# vercel
.vercel
Expand Down
13 changes: 0 additions & 13 deletions democrasite-frontend/api/auto/.openapi-generator/FILES

This file was deleted.

Loading

0 comments on commit 8cec24c

Please sign in to comment.