from allauth.account.views import confirm_email from dj_rest_auth.views import ( LoginView, LogoutView, PasswordChangeView, UserDetailsView) admin.site.site_header = 'GuOJ 后台管理' routers = routers.DefaultRouter() routers.register('users', UserViewSet, basename='user') routers.register('problemsets', ProblemSetViewSet, basename='problemset') routers.register('problems', ProblemViewSet, basename='problem') routers.register('notice', NoticeViewSet, basename='notice') urlpatterns = [ path('admin/', admin.site.urls), path('api/', include(routers.urls)), re_path(r'^api/auth/login/$', LoginView.as_view(), name='rest_login'), # URLs that require a user to be logged in with a valid session / token. re_path(r'^api/auth/logout/$', LogoutView.as_view(), name='rest_logout'), re_path(r'^api/auth/user/$', UserDetailsView.as_view(), name='rest_user_details'), re_path(r'^api/auth/password/change/$', PasswordChangeView.as_view(), name='rest_password_change'), re_path(r'^api/auth/password/reset/', include('django_rest_passwordreset.urls', namespace='password_reset')), path('api/auth/registration/', include('dj_rest_auth.registration.urls')), ] urlpatterns += staticfiles_urlpatterns()
PasswordResetConfirmView, PasswordResetView, UserDetailsView, ) urlpatterns = [ # URLs that do not require a session or valid token path('password/reset/', PasswordResetView.as_view(), name='rest_password_reset'), path('password/reset/confirm/', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'), path('login/', LoginView.as_view(), name='rest_login'), # URLs that require a user to be logged in with a valid session / token. path('logout/', LogoutView.as_view(), name='rest_logout'), path('user/', UserDetailsView.as_view(), name='rest_user_details'), path('password/change/', PasswordChangeView.as_view(), name='rest_password_change'), ] if getattr(settings, 'REST_USE_JWT', False): from rest_framework_simplejwt.views import TokenVerifyView from dj_rest_auth.jwt_auth import get_refresh_view urlpatterns += [ path('token/verify/', TokenVerifyView.as_view(), name='token_verify'), path('token/refresh/', get_refresh_view().as_view(),
PasswordResetConfirmView, PasswordResetView, UserDetailsView) from django.conf.urls import url from django.conf import settings urlpatterns = [ # URLs that do not require a session or valid token url(r'^password/reset/$', PasswordResetView.as_view(), name='rest_password_reset'), url(r'^password/reset/confirm/$', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'), url(r'^login/$', LoginView.as_view(), name='rest_login'), # URLs that require a user to be logged in with a valid session / token. url(r'^logout/$', LogoutView.as_view(), name='rest_logout'), url(r'^user/$', UserDetailsView.as_view(), name='rest_user_details'), url(r'^password/change/$', PasswordChangeView.as_view(), name='rest_password_change'), ] if getattr(settings, 'REST_USE_JWT', False): from rest_framework_simplejwt.views import ( TokenRefreshView, TokenVerifyView, ) urlpatterns += [ url(r'^token/verify/$', TokenVerifyView.as_view(), name='token_verify'),
# Third Party from dj_rest_auth.views import ( LoginView, LogoutView, PasswordChangeView, PasswordResetConfirmView, PasswordResetView, ) # Squarelet from squarelet.auth_helpers import views app_name = "auth_helpers" urlpatterns = [ path("check/", view=views.check, name="check"), path("password/reset/", PasswordResetView.as_view(), name="rest_password_reset"), path( "password/reset/confirm/", PasswordResetConfirmView.as_view(), name="rest_password_reset_confirm", ), path("login/", LoginView.as_view(), name="rest_login"), # URLs that require a user to be logged in with a valid session / token. path("logout/", LogoutView.as_view(), name="rest_logout"), path("password/change/", PasswordChangeView.as_view(), name="rest_password_change"), ]
from django.contrib import admin from django.urls import path, include from .views import * from . import views from dj_rest_auth.views import (LogoutView) urlpatterns = [ path('auth/', GithubLogin.as_view()), path('logout/', LogoutView.as_view()), ]
- Every access token has limitation about 5 minutes,after that it will expired.So you should get new access token by refresh token wich you earlier get for your credential, in this path: api/accounts/token/refresh/ ====================================== API AUTHENTICATION ======================================= """ urlpatterns = [ path('admin/', admin.site.urls), path('api/', include('api.urls')), # ================================ API AUTHECTICATION ====================================== path('api/accounts/', include('dj_rest_auth.urls')), # Auth path('api/accounts/login/', LoginView.as_view(), name='rest_login'), path('api/accounts/logout/', LogoutView.as_view(), name='rest_logout'), path('api/accounts/register/', include('dj_rest_auth.registration.urls')), path('api/accounts/user/', UserDetailsView.as_view(), name='rest_user_details'), # Password path('api/accounts/password/reset/', PasswordResetView.as_view(), name='rest_password_reset'), path('api/accounts/password/reset/confirm/<uidb64>/<token>/', PasswordResetConfirmView.as_view(), name='password_reset_confirm'), path('api/accounts/password/change/', PasswordChangeView.as_view(), name='rest_password_change'), # Token
from django.urls import path from dj_rest_auth.views import LogoutView from . import views app_name = "api" urlpatterns = [ path("auth/login/wca/", views.WCALoginView.as_view(), name="wca-login"), path("auth/logout/", LogoutView.as_view(), name="wca-logout"), path("user/", views.UserRetrieveAPIView.as_view(), name="user-retrieve"), path( "user/region-update-requests/", views.RegionUpdateRequestListCreateAPIView.as_view(), name="region-update-request-list", ), path("regions/", views.RegionListAPIView.as_view(), name="region-list"), path("events/", views.EventListAPIView.as_view(), name="event-list"), path("zones/", views.ZoneListAPIView.as_view(), name="zone-list"), path( "rankings/national-single/<str:event_id>/", views.NationalRankingSingleAPIView.as_view(), name="national-single-ranking", ), path( "rankings/national-average/<str:event_id>/", views.NationalRankingAverageAPIView.as_view(), name="national-average-ranking", ), path( "rankings/regional-single/<str:region_id>/<str:event_id>/", views.RegionalRankingSingleAPIView.as_view(),
from django.conf import settings from django.urls import path, include from django.conf.urls import url, re_path #from allauth.account.views import LoginView from dj_rest_auth.registration.views import RegisterView, VerifyEmailView, ConfirmEmailView from dj_rest_auth.views import LoginView, LogoutView, PasswordResetView, PasswordResetConfirmView, PasswordChangeView from rest_framework_simplejwt.views import TokenVerifyView, TokenObtainPairView, TokenRefreshView from dj_rest_auth.jwt_auth import get_refresh_view urlpatterns = [ path('admin/', admin.site.urls), path('', include('post.urls', namespace='posts')), path('', include('profiles.urls', namespace='profile')), path('api-auth/', include('rest_framework.urls')), path('login/', LoginView.as_view(), name='account_signin'), path('logout/', LogoutView.as_view(), name='account_login'), path('signup/', RegisterView.as_view(), name='account_signup'), path('verify-email/', VerifyEmailView.as_view(), name='rest_verify_email'), path('account/confirm-email/', VerifyEmailView.as_view(), name='account_email_verification_sent'), re_path(r'^account/confirm-email/(?P<key>[-:\w]+)/$', VerifyEmailView.as_view(), name='account_confirm_email'), path('account/confirm-email/<str:key>/', ConfirmEmailView.as_view()), path('account/password/change/', PasswordChangeView.as_view(), name='account_change_password'), path('account/password-reset/', PasswordResetView.as_view(), name='password_reset'),
from dj_rest_auth.views import (LoginView, PasswordChangeView, LogoutView) from django.urls import path from members.views import (SignupView, MemberDeleteView, MemberInfoView, MemberInfoCreateView, MemberImagesView, MemberPersonalitiesView, MemberRibbonsView) urlpatterns = [ path('auth/signup/', SignupView.as_view()), path('auth/login/', LoginView.as_view()), path('auth/logout/', LogoutView.as_view()), path('auth/password/change/', PasswordChangeView.as_view()), path('auth/delete/', MemberDeleteView.as_view()), path('member/images/', MemberImagesView.as_view()), path('member/personalities/', MemberPersonalitiesView.as_view()), path('member/info/', MemberInfoView.as_view()), path('member/info/create/', MemberInfoCreateView.as_view()), path('member/ribbons/', MemberRibbonsView.as_view()), ]