55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
from django.contrib import admin
|
|
from django.urls import include, path
|
|
from rest_framework_simplejwt.views import TokenRefreshView
|
|
|
|
from allauth.socialaccount.providers.apple.views import AppleOAuth2Adapter
|
|
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
|
|
from allauth.socialaccount.providers.oauth2.client import OAuth2Client
|
|
from dj_rest_auth.registration.views import SocialLoginView
|
|
|
|
from .views import public_feed
|
|
|
|
|
|
class GoogleLoginView(SocialLoginView):
|
|
adapter_class = GoogleOAuth2Adapter
|
|
client_class = OAuth2Client
|
|
|
|
|
|
class AppleLoginView(SocialLoginView):
|
|
adapter_class = AppleOAuth2Adapter
|
|
client_class = OAuth2Client
|
|
|
|
|
|
urlpatterns = [
|
|
path('admin/', admin.site.urls),
|
|
# Auth
|
|
path('api/auth/', include('dj_rest_auth.urls')),
|
|
path('api/auth/registration/', include('dj_rest_auth.registration.urls')),
|
|
path('api/auth/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
|
# Social / external IDP
|
|
# Mobile flow: POST {"access_token": "<idp_token>"} → returns JWT pair
|
|
path('api/auth/social/google/', GoogleLoginView.as_view(), name='google_login'),
|
|
path('api/auth/social/apple/', AppleLoginView.as_view(), name='apple_login'),
|
|
# Users app
|
|
path('api/users/', include('apps.users.urls')),
|
|
# Gears app
|
|
path('api/', include('apps.gears.urls')),
|
|
# Tools app
|
|
path('api/', include('apps.tools.urls')),
|
|
# Photos app
|
|
path('api/photos/', include('apps.photos.urls')),
|
|
# Sessions app
|
|
path('api/', include('apps.sessions.urls')),
|
|
# Calibers app
|
|
path('api/', include('apps.calibers.urls')),
|
|
# Social app (messages, blog, bugs, friends)
|
|
path('api/', include('apps.social.urls')),
|
|
# Public feed
|
|
path('api/feed/', public_feed, name='public-feed'),
|
|
]
|
|
|
|
if settings.DEBUG:
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|