Пример #1
0
 def create(self, request):
     data = request.data
     serializer = self.get_serializer(data=data)
     serializer.is_valid(raise_exception=True)
     serializer.save()
     self.user = User.objects.get(username=serializer.data.get('username'))
     if getattr(settings, 'REST_USE_JWT', False):
         self.access_token, self.refresh_token = jwt_encode(self.user)
     else:
         self.token = create_token(self.token_model, self.user,
                                   self.serializer)
     data = login.get_response(self).data
     return Response(data=data, status=status.HTTP_201_CREATED)
Пример #2
0
    LogoutView,
    PasswordChangeView,
    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'),
Пример #3
0
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()
Пример #4
0
# 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"),
]
Пример #5
0
from dj_rest_auth.views import (LoginView, LogoutView, PasswordChangeView,
                                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(),
Пример #6
0
from django.urls import path, re_path
from dj_rest_auth.registration.views import RegisterView, VerifyEmailView, ConfirmEmailView
from dj_rest_auth.views import LoginView, LogoutView

urlpatterns = [
    path('register/', RegisterView.as_view()),
    path('login/', LoginView.as_view()),
    path('logout/', LogoutView.as_view()),
    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()),
]
Пример #7
0
for example -> Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1Ni...

- 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'),
Пример #8
0
from django.contrib import admin
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(),
Пример #9
0
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()),
]