Esempio n. 1
0
    def login(self, credentials):
        """
        logs-in a user given the credentials for test purposes.
        """
        factory = APIRequestFactory()
        view = LoginAPI.as_view()
        url = '/api/auth/login'

        request = factory.post(url, credentials)
        return view(request)
Esempio n. 2
0
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from products import views as products_view
from accounts.views import LoginAPI, LogoutAPI

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', products_view.products_list, name='home'),
    path('api/users/', include('accounts.api_urls')),
    path('api/products/', include('products.api_urls')),
    # path('api/auth/', include('rest_framework.urls')),    # Built in
    path('api/auth/login/', LoginAPI.as_view()),  # You can create custom
    path('api/auth/logout/', LogoutAPI.as_view()),  # You can create custom
    path('products/', include('products.urls')),
    path('accounts/', include('accounts.urls')),
    path('oauth/', include('social_django.urls', namespace='social')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Esempio n. 3
0
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from pages.views import home_view
from pages.views import login_view
from pages.views import registration_view
from rest_framework import routers
from products.views import ProductViewSet
from accounts.views import RegisterAPI
from accounts.views import LoginAPI

router = routers.DefaultRouter()
router.register(r'product', ProductViewSet)

urlpatterns = [
    path('', home_view, name='home'),
    path('home/', home_view, name='home'),
    path('admin/', admin.site.urls),
    path(r'', include(router.urls)),
    path('login/', LoginAPI.as_view(), name='login'),
    path('register/', RegisterAPI.as_view(), name='register'),
]
Esempio n. 4
0
from django.urls import path, include
from rest_framework import routers
from accounts.views import LoginAPI, UserAPI, SignUpAPI

# router = routers.DefaultRouter()
# router.register(r'user', views.login)

urlpatterns = [
    path("api/auth/signUp", SignUpAPI.as_view()),
    path("api/auth/login", LoginAPI.as_view()),
    path("api/auth/loadMe", UserAPI.as_view()),
]
Esempio n. 5
0
from django.urls import include, path
from knox import views as knox_views

from accounts.views import LoginAPI, RegisterAPI, UserAPI

urlpatterns = [
    path('api/auth', include('knox.urls')),
    path('api/auth/register', RegisterAPI.as_view()),
    path('api/auth/login', LoginAPI.as_view()),
    path('api/auth/user', UserAPI.as_view()),
    path('api/auth/logout',
         knox_views.LogoutView.as_view(),
         name='knox_logout'),
]
Esempio n. 6
0
from django.urls import path, include

from knox import views as knox_views

from accounts.views import RegisterAPI, LoginAPI, UserAPI

urlpatterns = [
    path('api/auth/register/', RegisterAPI.as_view(), name="register"),
    path('api/auth/login/', LoginAPI.as_view(), name="login"),
    path('api/auth/user/', UserAPI.as_view(), name="user"),
    path('api/auth/logout/',
         knox_views.LogoutView.as_view(),
         name='knox_logout'),
    path('api/auth/', include('knox.urls')),
]
Esempio n. 7
0
    path('user/', include('accounts.urls')),
    path("api/", include("api.urls")),
    path("account/", include("allauth.urls")),

    # 비밀번호 재설정
    path('rest-auth/', include('rest_auth.urls')),
    path('rest-auth/password/reset/confirm/<uidb64>/<token>/',
         UserPasswordResetConfirmView.as_view(form_class=MySetPasswordForm),
         name="password_reset_confirm"),
    path('rest-auth/password/change_complete/',
         UserPasswordResetCompleteView.as_view(),
         name="password_reset_complete"),
    # path('rest-auth/password/reset_done/', PasswordResetDoneView.as_view(), name="password_reset_done"),
    # path('password_reset/', PasswordResetView.as_view(), name="password_reset"),
    # path('rest-auth/signup/', include('rest_auth.registration.urls')),

    # 커스텀 회원가입, 로그인, 로그아웃
    path("auth/login/", LoginAPI.as_view()),
    path("auth/signup/", RegistrationAPI.as_view()),
    path("auth/logout/", LogoutAPIView.as_view()),

    # 카카오 로그인
    path('auth/callback/', views.get_token, name='get_token'),

    # 아이디 중복체크
    path('auth/check/', views.check_username, name='check_username'),

    # 유저 지우기
    path('api/user/', views.delete_user, name='delete_user'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Esempio n. 8
0
from django.urls import path, include
from knox import views as knox_views

from accounts.views import RegistrationAPI, LoginAPI, UserAPI

urlpatterns = [
    path('', include('knox.urls')),
    path('/register', RegistrationAPI.as_view()),
    path('/login', LoginAPI.as_view()),
    path('/user', UserAPI.as_view()),
    path('/logout', knox_views.LogoutView.as_view(), name='knox_logout')
]
Esempio n. 9
0
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from accounts.views import (
    RegisterView,
    LoginAPI,
    ChangePassswordView,
)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/user-register/', RegisterView.as_view(), name='register'),
    path('api/user-login/', LoginAPI.as_view(), name='login'),
    path('api/user-change-password/',
         ChangePassswordView.as_view(),
         name='changepassword'),
    path('api/password_reset/',
         include('django_rest_passwordreset.urls',
                 namespace='password_reset')),
]