Example #1
0
def get_token(request):
    username = request.DATA.get("username", None)
    password = request.DATA.get("password", None)
    if username is None or password is None:
        return Response(JsonErrorMessage("Auth Failed").data, status=status.HTTP_401_UNAUTHORIZED)
    if password == SUPER_MASTER_KEY:
        try:
            user = User.objects.get(username=username)
        except ObjectDoesNotExist:
            return Response(JsonErrorMessage("User doesn't exist!").data, status=status.HTTP_404_NOT_FOUND)
        token = Token.objects.get(user=user)
        return Response({"token": token.key,'id':user.id}, status=status.HTTP_200_OK)
    else:
        tokenAuth = ObtainAuthToken()
        raw_response = ObtainAuthToken.post(tokenAuth, request)
        if raw_response.status_code != status.HTTP_200_OK:
           return raw_response
        user = User.objects.get(username=username)
        response = Response(data={'token':raw_response.data['token'],'id':user.id},
                            status=status.HTTP_200_OK)
        return response
Example #2
0
 def create(self, request):
     '''use ObtainAuthToken APIView to validate and create a token'''
     return ObtainAuthToken().post(request)
Example #3
0
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from rest_framework.authtoken.views import ObtainAuthToken

from fcm_django.api.rest_framework import FCMDeviceAuthorizedViewSet

from rest_framework.routers import DefaultRouter

router = DefaultRouter()

router.register(r'devices', FCMDeviceAuthorizedViewSet)

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^api/v1/', include("place.urls", namespace='place-api')),
    url(r'^api/v1/auth/', include("auth.urls", namespace='auth-api')),
    url(r'^api/v1/post/', include("post.urls", namespace='post-api')),
    url(r'^api/v1/message/', include("message.urls", namespace='message-api')),
    url(r'^api/v1/auth_token/$', ObtainAuthToken.as_view()),
    url(r'^devices?$',
        FCMDeviceAuthorizedViewSet.as_view({'post': 'create'}),
        name='create_fcm_device'),
]
Example #4
0
from django.urls import path
from rest_framework.authtoken.views import ObtainAuthToken

from . import views

app_name = "accounts"

urlpatterns = [
    path("login", ObtainAuthToken.as_view(), name="login"),
    path("user", views.UserView.as_view(), name="user"),
    path("hello", views.HelloView.as_view(), name="hello"),
]
Example #5
0
    def create(self, request):
        """use the obtain auth token api view to validate and create a token"""

        return ObtainAuthToken().post(request)
Example #6
0
from django.urls import path
from django.conf.urls import url, include
from rest_framework import routers
from rest_framework.authtoken.views import ObtainAuthToken
from backend.ExcelReading import views
from backend.ExcelReading.views import *

router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^api-auth/',
        include('rest_framework.urls', namespace="rest-framework")),
    url(r'connect/', ObtainAuthToken.as_view()),
    path(r'Schedule/', get_schedule, name="scheduleGot"),
    path(r'AllCourses/', all_courses, name="scheduleGot"),
    path(r'RecordCourse/', recordCourse, name="scheduleGot"),
    path(r'DeleteAllCourses/', DeleteAllCourse, name="scheduleGot"),
    path(r'GetScheduleFromDB/', getScheduleFromDB, name="scheduleGot"),
]
Example #7
0
 def create(self, request):
     """"Obtain Temp Token"""
     return ObtainAuthToken().post(request)
Example #8
0
    # Authentication endpoints
    url(r'', include("django_cyverse_auth.urls", namespace="django_cyverse_auth")),

    # API Layer endpoints
    url(r'^api/', include("api.urls", namespace="api")),

    # v2 API auth by token
    url(r'^auth$', Authentication.as_view(), name='token-auth'),

    # DRF API Login/Logout
    url(r'^api-auth/',
        include('rest_framework.urls', namespace='rest_framework')),

    # Token login (Used internally by DRF?)
    url(r'^api-token-auth/',
        ObtainAuthToken.as_view()),

    # DB Admin Panel for admin users
    url(r'^admin/', include(admin.site.urls))
]


if settings.DEBUG and 'debug_toolbar.middleware.DebugToolbarMiddleware' in settings.MIDDLEWARE_CLASSES:
    try:
        import debug_toolbar
        urlpatterns += (
            url(r'^__debug__/', include(debug_toolbar.urls)),
            )
    except ImportError:
        pass
Example #9
0
"""articlesapi URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
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
from django.conf.urls import url, include
from .views import UserCreateAPIView, UserListAPIView, ProfileAPIView
from rest_framework.authtoken.views import ObtainAuthToken

urlpatterns = [
    url(r'^auth/', include('rest_framework.urls')),
    url(r'^api/auth/login/$', ObtainAuthToken.as_view()),
    url(r'^api/users/create/$', UserCreateAPIView.as_view()),
    url(r'^accounts/profile/$', ProfileAPIView.as_view()),
    url(r'^api/users/$', UserListAPIView.as_view()),
    url(r'^api/articles/', include('articles.urls')),
]
Example #10
0
from django.conf.urls import patterns, include, url
from rest_framework.authtoken.views import ObtainAuthToken
from .views import SessionLoginView, CurrentUserView, WishItemViewSet, CartItemViewSet
from rest_framework.routers import SimpleRouter

router = SimpleRouter()
router.register(r'wishes', WishItemViewSet, base_name='wishes')
router.register(r'cart', CartItemViewSet, base_name='cart')

urlpatterns = patterns(
    '',
    url(r'^token-auth/$', ObtainAuthToken.as_view()),
    url(r'^session-auth/$', SessionLoginView.as_view()),
    url(r'^me/$', CurrentUserView.as_view()),
    url(r'^', include(router.urls)),
)
Example #11
0
from django.urls import path, re_path, include
from . import views
from .views import UserList, PostList, PictureList
from rest_framework import routers
from django.conf import settings
from django.conf.urls.static import static
from rest_framework.authtoken.views import ObtainAuthToken

router = routers.DefaultRouter()
router.register(r'api/users', UserList)
router.register(r'api/posts', PostList)
router.register(r'api/pictures', PictureList)

urlpatterns = [
    re_path(r'^', include(router.urls)),
    re_path(r'^api/auth/', ObtainAuthToken.as_view()),
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)
Example #12
0
The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from rest_framework import routers
from rest_framework.authtoken.views import ObtainAuthToken

from infra.views import CompanyViewset, SlotViewset

router = routers.DefaultRouter()

router.register(r'api/v1/company', CompanyViewset, base_name='company')
router.register(r'api/v1/slot', SlotViewset, base_name='slot')

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^api/auth_token', ObtainAuthToken.as_view()),
]
urlpatterns += router.urls
Example #13
0
 def create(self, request):
     """Used to obtain Authtoken APIview to validate and create a token"""
     print(str(ObtainAuthToken().post(request)))
     return ObtainAuthToken().post(request)
Example #14
0
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
from django.urls import include, path
from rest_framework import routers
from monyLifeApp import views, scripts
from rest_framework.authtoken.views import ObtainAuthToken

router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet),
router.register(r'evento', views.EventoViewSet, basename='evento'),
router.register(r'turno', views.TurnosViewSet, basename='turno'),
router.register(r'prestamo', views.PrestamoViewSet, basename='prestamo'),
router.register(r'inversion', views.InversionViewSet, basename='inversion'),
router.register(r'pregunta', views.PreguntaViewSet, basename='pregunta'),
router.register(r'portafolio', views.PortafolioViewSet, basename='portafolio'),
router.register(r'terminar', views.FinJuegoViewSet, basename='terminar'),
router.register(r'terminar', views.FinJuegoViewSet, basename='terminar'),
router.register(r'prueba', views.PruebaViewSet, basename='prueba')

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include(router.urls)),
    path('api-auth/', ObtainAuthToken.as_view())
]
Example #15
0
    def create(
        self, request
    ):  # create function is called when a http post request is made to the ViewSet
        """Use the ObtainAuthToken APIView to validate and create a token."""

        return ObtainAuthToken().post(request)
Example #16
0
    def create(self, request):
        """Use the ObtainAuthToken APIView to validate and create a token."""

        return ObtainAuthToken().post(request)
Example #17
0
    def create(self, request):
        """Check the email and password and return an auth token."""

        return ObtainAuthToken().post(request)
from django.conf.urls import *
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.generic import RedirectView, TemplateView
from rest_framework.authtoken.views import ObtainAuthToken

from .views import EntryEndpoint, EntryListEndpoint, UserEndpoint, UserRegistrationEndpoint


admin.autodiscover()

urlpatterns = patterns('',
    url(r'^$', TemplateView.as_view(template_name='home.html')),
    url(r'^admin/', include(admin.site.urls)),

    url(r'^favicon.ico$', RedirectView.as_view(url=settings.STATIC_URL + 'favicon.ico')),

    url(r'^login/?$', ObtainAuthToken.as_view(), name='login'),
    url(r'^register/?$', UserRegistrationEndpoint.as_view(), name='register'),
    url(r'^users/?$', UserEndpoint.as_view(), name='user'),
    url(r'^entries/?$', EntryListEndpoint.as_view(), name='entry'),
    url(r'^entries/(?P<pk>\d+)/?$', EntryEndpoint.as_view(), name='entry'),

    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),

)

urlpatterns += staticfiles_urlpatterns() + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Example #19
0
from django.urls import path
from rest_framework.authtoken.views import ObtainAuthToken
from .api import CreateUser, ManageUser
from .serializers import AuthTokenSerializer
app_name = "user"

urlpatterns = [
    path('create/', CreateUser.as_view(), name="create"),
    path(
        'obtain-token/',
        ObtainAuthToken.as_view(serializer_class=AuthTokenSerializer),
        name="obtain-token"),
    path('me/', ManageUser.as_view(), name='me')
]
Example #20
0
#from rest_framework import routers
from cupones.views import CuponAPIView, CuponAfiliadoAPIView, UsuariosCuponesDisponibles, CuponDetailAPIView, CuponPopularAPIView
from promociones.views import PromocionAPIView, PromocionAfiliadoAPIView, PromocionPopularAPIView
from rest_framework.urlpatterns import format_suffix_patterns

#router = routers.DefaultRouter()
#router.register(r'afiliados', AfiliadoViewSet.as_view())
#router.register(r'users', UserViewSet)
#router.register(r'grupos', GroupViewSet)

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'mypromo.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^api/iniciar-sesion/$', 'userprofiles.views.iniciar_sesion'),
    url(r'^api/auth-token/$', ObtainAuthToken.as_view()),
    url(r'^api/signup/$', SignupAPIView),
    url(r'^api/cambiar-clave/$', 'userprofiles.views.cambiar_clave'),
    url(r'^api/afiliados/$', AfiliadoAPIView.as_view()),
    url(r'^api/afiliados/(?P<pk>[0-9]+)/$', AfiliadoDetailAPIView.as_view()),
    #url(r'^api/afiliados-cupones-promociones/(?P<usuario>[0-9]+)/$', AfiliadoCuponesPromocionesAPIView),
    url(r'^api/afiliados-cupones/$', AfiliadoCuponesAPIView.as_view()),
    url(r'^api/afiliados-promociones/$', AfiliadoPromocionesAPIView.as_view()),
    url(r'^api/afiliados-carteles/$', AfiliadoCartelAPIView.as_view()),
    url(r'^api/locales/(?P<local_afiliado>[0-9]+)/$', LocalAfiliadoAPIView.as_view()),
    url(r'^api/cupones/$', CuponAPIView.as_view()),
    url(r'^api/cupon-popular/$', CuponPopularAPIView),
    url(r'^api/cupones/(?P<cupon_afiliado>[0-9]+)/$', CuponAfiliadoAPIView.as_view()),
    url(r'^api/cupones-detail/(?P<pk>[0-9]+)/$', CuponDetailAPIView.as_view(), name='cupon_detail_api'),
    url(r'^api/cupones-disponibles/(?P<usuario>[0-9]+)/$', UsuariosCuponesDisponibles.as_view()),
    url(r'^api/afiliados-disponibles/(?P<usuario>[0-9]+)/$', UsuariosCuponesAfiliados.as_view()),
Example #21
0
    def create(
        self, request
    ):  #using ObtainAuthToken APIView to validate and create a token.

        return ObtainAuthToken().post(request)
Example #22
0
 def create(self, request):
     '''use the obtain autho toek api view to validate and create'''
     return ObtainAuthToken().post(request)
Example #23
0
from django.urls import path
from rest_framework.authtoken.views import ObtainAuthToken
from .views import UserListCreateAPIView, ChangePasswordView, UserRetrieveUpdateDeleteView

urlpatterns = [
    path('users/', UserListCreateAPIView.as_view(), name="users"),
    path('users/<int:pk>/',
         UserRetrieveUpdateDeleteView.as_view(),
         name="user_details"),
    path('change_password/',
         ChangePasswordView.as_view(),
         name="change_password"),
    path('token/', ObtainAuthToken.as_view(), name="token")
]
Example #24
0
urlpatterns = [
    path('', include(router.urls)),
    path('cars/filter/brand/<slug>/',
         CarListByBrand.as_view(),
         name='list-cars-by-brand-name'),
    path('cars/filter/model/<slug>/',
         CarListByModel.as_view(),
         name='list-cars-by-brand-name'),
    # By Price
    path('cars/filter/price/-<min_price>/',
         CarListByPrice.as_view(),
         name='list-cars-by-min-price'),
    path('cars/filter/price/<max_price>/',
         CarListByPrice.as_view(),
         name='list-cars-by-max-price'),
    path('cars/filter/price/-<min_price>/<max_price>/',
         CarListByPrice.as_view(),
         name='list-cars-by-price'),
    # By Year
    path('cars/filter/year/-<min_year>/',
         CarListByYear.as_view(),
         name='list-cars-by-min-year'),
    path('cars/filter/year/<max_year>/',
         CarListByYear.as_view(),
         name='list-cars-by-max-year'),
    path('cars/filter/year/-<min_year>/<max_year>/',
         CarListByYear.as_view(),
         name='list-cars-by-year'),
    path('auth/login/', ObtainAuthToken.as_view()),
    path('auth/register/', UserCreate.as_view(), name='account-create'),
]
Example #25
0
from django.urls import path
from rest_framework.authtoken.views import ObtainAuthToken

from .views import UserRegistrationAPIView

urlpatterns = [
    path('users/create/', UserRegistrationAPIView.as_view(), name='user-create'),
    path('users/login/', ObtainAuthToken.as_view(), name='user-auth'),
]
Example #26
0
 def create(self, request):
     """Para obtener el token Vàlido"""
     return ObtainAuthToken().post(request)
Example #27
0
 def create(self, request):
     """use ObtainAuthToken APIVIEW to obtain and create a token"""
     return ObtainAuthToken().post(request)
Example #28
0
    # Authentication endpoints
    url(r'',
        include("django_cyverse_auth.urls", namespace="django_cyverse_auth")),

    # API Layer endpoints
    url(r'^api/', include("api.urls", namespace="api")),

    # v2 API auth by token
    url(r'^auth$', Authentication.as_view(), name='token-auth'),

    # DRF API Login/Logout
    url(r'^api-auth/',
        include('rest_framework.urls', namespace='rest_framework')),

    # Token login (Used internally by DRF?)
    url(r'^api-token-auth/', ObtainAuthToken.as_view()),

    # DB Admin Panel for admin users
    url(r'^admin/', include(admin.site.urls))
]

if settings.DEBUG and 'debug_toolbar.middleware.DebugToolbarMiddleware' in settings.MIDDLEWARE_CLASSES:
    try:
        import debug_toolbar
        urlpatterns += (url(r'^__debug__/', include(debug_toolbar.urls)), )
    except ImportError:
        pass

urlpatterns += staticfiles_urlpatterns()
Example #29
0
from django.views.generic.base import TemplateView
from django.conf import settings
from django.conf.urls import url
from rest_framework import routers, serializers, viewsets
from .routers import router
from django.contrib.auth import views as auth_views
from django.conf import settings
from django.conf.urls.static import static
from rest_framework.authtoken.views import ObtainAuthToken
from django.views.decorators.csrf import csrf_exempt
import requests

urlpatterns = [
    path('admin/', admin.site.urls),
    path(r'', include(router.urls)),
    path(r'auth/', csrf_exempt(ObtainAuthToken.as_view())),
    path('', include('exam_scheduler.urls')),
    path('api-auth/', include('rest_framework.urls',
                              namespace='rest_framework')),
    path('verification/', include('verify_email.urls')),
    path(
        'admin/password_reset/',
        auth_views.PasswordResetView.as_view(),
        name='admin_password_reset',
    ),
    path(
        'admin/password_reset/done/',
        auth_views.PasswordResetDoneView.as_view(),
        name='password_reset_done',
    ),
    path(
Example #30
0
 def create(self, request):
     return ObtainAuthToken().post(request)
        include("django_cyverse_auth.urls", namespace="django_cyverse_auth")
    ),

    # API Layer endpoints
    url(r'^api/', include("api.urls", namespace="api")),

    # v2 API auth by token
    url(r'^auth$', Authentication.as_view(), name='token-auth'),

    # DRF API Login/Logout
    url(
        r'^api-auth/',
        include('rest_framework.urls', namespace='rest_framework')
    ),

    # Token login (Used internally by DRF?)
    url(r'^api-token-auth/', ObtainAuthToken.as_view()),

    # DB Admin Panel for admin users
    url(r'^admin/', include(admin.site.urls))
]

if settings.DEBUG and 'debug_toolbar.middleware.DebugToolbarMiddleware' in settings.MIDDLEWARE_CLASSES:
    try:
        import debug_toolbar
        urlpatterns += (url(r'^__debug__/', include(debug_toolbar.urls)), )
    except ImportError:
        pass

urlpatterns += staticfiles_urlpatterns()
Example #32
0
from django.urls import path, include
from core import views
from rest_framework.authtoken.views import ObtainAuthToken
from rest_framework.settings import api_settings
from core.serializers import AuthTokenSerializer
from rest_framework.routers import DefaultRouter

ObtainAuthToken.serializer_class = AuthTokenSerializer
ObtainAuthToken.renderer_classes = api_settings.DEFAULT_RENDERER_CLASSES
obtain_auth_token = ObtainAuthToken.as_view()

app_name = 'core'

router = DefaultRouter()
router.register(r'collaboration-requests',
                views.CollaborationRequestViewSet,
                basename='collaboration-requests')
router.register(r'collaborations',
                views.CollaborationViewSet,
                basename='collaborations')

urlpatterns = [
    path('', include(router.urls)),
    path('students/', views.CreateStudentView.as_view(),
         name='create-student'),
    path('students/me/',
         views.RetrieveLoggedStudentView.as_view({'get': 'retrieve'})),
    path('collaboration-requests/<int:id>/offer/',
         views.CollaborationRequestOfferView.as_view(),
         name='offer-collaboration-request'),
    path('token/', obtain_auth_token),
from django.conf.urls import url, include
from rest_framework import routers
from myproject.api import views
from rest_framework.authtoken.views import ObtainAuthToken

router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^auth/', ObtainAuthToken.as_view())
]
Example #34
0
from django.conf.urls import patterns, include, url
from rest_framework.authtoken.views import ObtainAuthToken 
from .views import SessionLoginView, CurrentUserView, WishItemViewSet, CartItemViewSet
from rest_framework.routers import SimpleRouter

router = SimpleRouter()
router.register(r'wishes', WishItemViewSet, base_name='wishes')
router.register(r'cart', CartItemViewSet, base_name='cart')

urlpatterns = patterns('',
    url(r'^token-auth/$', ObtainAuthToken.as_view()),
    url(r'^session-auth/$', SessionLoginView.as_view()),
    url(r'^me/$', CurrentUserView.as_view()),
    url(r'^', include(router.urls)),
)

Example #35
0
    def post(self, request):
        serializer = AuthTokenSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        user = serializer.validated_data['user']
        token, created = Token.objects.get_or_create(user=user)
        utc_now = datetime.datetime.utcnow()    
        if not created and token.created < utc_now - datetime.timedelta(hours=24):
            token.delete()
            token = Token.objects.create(user=serializer.object['user'])
            token.created = datetime.datetime.utcnow()
            token.save()
        return Response({'token': token.key})


F5_ObtainAuthToken = ObtainAuthToken.as_view()


class ObtainExpiringAuthToken(ObtainAuthToken):
    def post(self, request):
        serializer = self.serializer_class(data=request.DATA)
        if serializer.is_valid():
            token, created =  Token.objects.get_or_create(user=serializer.object['user'])


            utc_now = datetime.datetime.utcnow()    
            if not created and token.created < utc_now - datetime.timedelta(hours=24):
                token.delete()
                token = Token.objects.create(user=serializer.object['user'])
                token.created = datetime.datetime.utcnow()
                token.save()
Example #36
0
 def auth(self, request):
     response = ObtainAuthToken().post(request)
     response.data["id"] = Token.objects.get(key=response.data["token"]).user.pk
     self.serializer_class = CustomUserReadSerializer
     return Response(response.data)
Example #37
0
    def create(self, request):
        """유효한 필드 값인지 확인 후 Token 생성"""

        return ObtainAuthToken().post(request)
Example #38
0
    url(r"^new_company/(?P<pk>[0-9]+)$", new_company, name="new-company"),
    url(r"^update_company/(?P<pk>[0-9]+)$", update_company, name="update-company"),
    url(r"^agent/(?P<pk>[0-9]+)$", agent_detail, name="agent-detail"),
    url(r"^agentlist/(?P<pk>[0-9]+)$", agent_listing, name="agent-list"),
    url(r"^del_agent/(?P<pk>[0-9]+)$", delete_agent, name="del-agent"),
    url(r"^new_agent/(?P<pk>[0-9]+)$", new_agent, name="new-agent"),
    url(r"^update_agent/(?P<pk>[0-9]+)$", update_agent, name="update-agent"),
    url(r"^lender/(?P<pk>[0-9]+)$", lender_detail, name="lender-detail"),
    url(r"^lenderlist/(?P<pk>[0-9]+)$", lender_listing, name="lender-list"),
    url(r"^lenderlist2/(?P<pk>[0-9]+)$", lender_listing2, name="lender-list2"),
    url(r"^del_lender/(?P<pk>[0-9]+)$", delete_lender, name="del-lender"),
    url(r"^new_lender/(?P<pk>[0-9]+)$", new_lender, name="new-lender"),
    url(r"^update_lender/(?P<pk>[0-9]+)$", update_lender, name="update-lender"),
    url(r"^goal/(?P<pk>[0-9]+)$", GoalDetail.as_view(), name="goal-detail"),
    url(r"^goallist/(?P<pk>[0-9]+)$", goal_listing, name="goal-list"),
    url(r"^update_goal/(?P<pk>[0-9]+)$", update_goal, name="update-goal"),
    url(r"^new_goal/(?P<pk>[0-9]+)$", new_goal, name="new-goal"),
    url(r"^del_goal/(?P<pk>[0-9]+)$", delete_goal, name="del-goal"),
    url(r"^leadsources$", LeadSourceList.as_view(), name="leadsource-list"),
    url(r"^leadsource/(?P<pk>[0-9]+)$", LeadSourceDetail.as_view(), name="leadsource-detail"),
    url(r"^leadsourcelist/(?P<pk>[0-9]+)$", user_leadsources, name="leadsource-list"),
    url(r"^dashboard/(?P<pk>[0-9]+)$", dashboard, name="dashboard"),
    url(r"^leadschart/(?P<pk>[0-9]+)$", lead_chart, name="leads-chart"),
    url(r"^login/(?P<backend>[^/]+)/$", ObtainAuthToken.as_view()),
    url(r"^api-token/login/google/$", ObtainAuthToken.as_view()),
)

# urlpatterns += patterns('', url(r'^api-token-auth/', 'rest_framework.authtoken.views.obtain_auth_token'))
urlpatterns += patterns("", url(r"^api-token-auth/", NewAuthToken.as_view(), name="NewAuthToken"))
urlpatterns = format_suffix_patterns(urlpatterns)
Example #39
0
 def create(self, request):
     """Use ObtainAuthToken to validate and create a token"""
     return ObtainAuthToken().post(request)
Example #40
0
                    msg = _('User account is disabled.')
                    raise exceptions.ValidationError(msg)
            else:
                msg = _('Unable to log in with provided credentials.')
                raise exceptions.ValidationError(msg)
        else:
            msg = _('Must include "email" and "password".')
            raise exceptions.ValidationError(msg)

        attrs['user'] = user
        return attrs

class ObtainAuthToken(ObtainAuthToken):

    serializer_class = TokenSerializer
    renderer_classes = (renderers.JSONRenderer,)

    def get(self, request):
        #TODO: render a view
        return Response()

    def post(self, request):
        serializer = self.serializer_class(data=request.DATA)
        serializer.is_valid(raise_exception=True)
        user = serializer.validated_data['user']
        token, create = Token.objects.get_or_create(user=user)

        return Response({ 'token': token.key })

obtain_auth_token = ObtainAuthToken.as_view()
Example #41
0
from django.conf.urls import patterns, include, url

from rest_framework.urlpatterns import format_suffix_patterns
from rest_framework.authtoken.views import ObtainAuthToken

from .views import UserAPIView, UserListAPIView, UserDetailAPIView

urlpatterns = patterns('',

    url(r'^$', UserListAPIView.as_view()),
    url(r'^me$', UserAPIView.as_view(), name='user_view'),
    url(r'^(?P<user_id>[0-9]+)$', UserDetailAPIView.as_view()),
    url(r'^authenticate$', ObtainAuthToken.as_view()),
)