Esempio n. 1
0
    def test_get_user(self):
        """
        Tests to get the currently logged user.
        """
        credentials = {
            'username': '******',
            'email': '*****@*****.**',
            'password': '******'
        }
        response = self.register(credentials)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

        credentials = {
            'username': '******',
            'password': '******'
        }

        response = self.login(credentials)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

        token = response.data['token']

        factory = APIRequestFactory()
        view = UserAPI.as_view()
        url = 'api/auth/user'

        request = factory.get(url, HTTP_AUTHORIZATION='Token {}'.format(token))
        response = view(request)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['username'], 'test')
Esempio n. 2
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. 3
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. 4
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')),
]
from django.urls import path, include
from accounts.views import RegisterAPI, LoginAPI, UserAPI
from knox import views as knox_views

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 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. 7
0
from django.urls import path, include
from accounts.views import RegisterAPI, LoginAPI, UserAPI
from knox import views as know_views
from rest_framework import routers

urlpatterns = [
    path('', include('knox.urls')),
    path('register', RegisterAPI.as_view()),
    path('login', LoginAPI.as_view()),
    path('account', UserAPI.as_view()),
    path('logout', know_views.LogoutView.as_view(), name='knox_logout')
]