def test_registration_duplicate():
    first_name = "Test Name"
    second_name = "Test Surname"
    email = '*****@*****.**'
    password = '******'

    request = HttpRequest()
    request.method = "post"
    request.META['HTTP_HOST'] = 'localhost'
    request.POST = {
        'first_name': first_name,
        'second_name': second_name,
        'password': password,
        'user_email': email
    }

    view = RegisterView.as_view()
    view(request)

    response = view(request)
    assert 'User for that email already exists!' in response.content.decode(
        'utf-8')
def test_registration_activation():
    first_name = "Test Name"
    second_name = "Test Surname"
    email = '*****@*****.**'
    password = '******'

    request = HttpRequest()
    request.method = "post"
    request.META['HTTP_HOST'] = 'localhost'
    request.POST = {
        'first_name': first_name,
        'second_name': second_name,
        'password': password,
        'user_email': email
    }

    view = RegisterView.as_view()
    view(request)

    user = User.objects.get(username=email)

    assert user is not None
    assert user.email == email
    assert user.is_active is False

    activate(
        HttpRequest(), urlsafe_base64_encode(force_bytes(user.pk)),
        account_activation_token._make_token_with_timestamp(
            user,
            account_activation_token._num_days(
                account_activation_token._today())))

    user = User.objects.get(username=email)
    assert user.is_active is True
    assert user.first_name == first_name

    user.delete()
Exemplo n.º 3
0
from django.urls import path, include
from rest_framework import routers
from authentication.views import UserViewSet, RegisterView, HelloWorldView
from rest_framework_simplejwt import views as jwt_views

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

urlpatterns = [
    path("", include(router.urls)),
    path('token/obtain/',
         jwt_views.TokenObtainPairView.as_view(),
         name='token_create'),  # override sjwt stock token
    path('token/refresh/',
         jwt_views.TokenRefreshView.as_view(),
         name='token_refresh'),
    path('register/', RegisterView.as_view(), name='auth_register'),
    path('hello/', HelloWorldView.as_view(), name='hello_world')
]
Exemplo n.º 4
0
from django.urls import path
from authentication.views import RegisterView, VerifyEmail, LoginAPIView
from rest_framework_simplejwt.views import (
    TokenRefreshView, )

urlpatterns = [
    path('register/', RegisterView.as_view(), name="register"),
    path('login/', LoginAPIView.as_view(), name="login"),
    path('email-verify/', VerifyEmail.as_view(), name="email-verify"),
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
]
Exemplo n.º 5
0
from django.urls import path, include

from rest_framework.routers import DefaultRouter

from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

from authentication.views import AuthApi, RegisterView, UserViewSet, ResetPasswordView

app_name = 'authentication'

router = DefaultRouter()
router.register('user', AuthApi)
router.register('users', UserViewSet)

urlpatterns = [
    path('token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('register/', RegisterView.as_view(), name='register_user'),
    path('register/<str:token>', RegisterView.as_view(), name='register_user_confirm'),
    path('reset-password/', ResetPasswordView.as_view(), name='reset_password'),
    path('reset-password/<str:token>/', ResetPasswordView.as_view(), name='reset_password_confirm'),
    path('', include(router.urls)),
]
Exemplo n.º 6
0
    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, re_path, include
from django.conf.urls.static import static
from curve import settings

from curve.views import IndexView
from authentication.views import LoginView, LogoutView, RegisterView

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

urlpatterns += [
    re_path(r'^admin/', admin.site.urls),
    re_path(r'^api/v1/dining/', include('dining.urls')),
    re_path(r'^api/v1/auth/login/$', LoginView.as_view(), name='login'),
    re_path(r'^api/v1/auth/register/$',
            RegisterView.as_view(),
            name='register'),
    re_path(r'^api/v1/auth/logout/$', LogoutView.as_view(), name='logout'),
    re_path(r'api-auth/',
            include('rest_framework.urls', namespace='rest_framework')),
    re_path(r'.*', IndexView.as_view(), name='index'),
]
Exemplo n.º 7
0
from django.urls import path

from authentication.views import CustomLoginView, RegisterView, CustomLogOutView

urlpatterns = [
    path('sign-in/', CustomLoginView.as_view(), name='login'),
    path('log-out/', CustomLogOutView.as_view(), name='logout'),
    path('sign-up/', RegisterView.as_view(), name='signup'),
]
Exemplo n.º 8
0
from report.views import ReportView, FolderView
from secureshare_messages.views import MessageInboxView, MessageSendView, MessageOutboxView, MessageDecryptView
from authentication.views import RegisterView, LoginView, LogoutView, SiteManagerView, GroupView

#router = routers.SimpleRouter()
#router.register(r'reports',ReportViewSet, base_name='Report')
#router.register(r'messages',MessageViewSet, base_name='Message')

urlpatterns = [
    # Examples:
    # url(r'^$', 'secureshare.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    #url(r'^api/v1/',include(router.urls)),
    url(r'^api/v1/users/register/', RegisterView.as_view()),
    url(r'^api/v1/users/login/', LoginView.as_view()),
    url(r'^api/v1/users/logout/', LogoutView.as_view()),
    url(r'api/v1/users/groups/', GroupView.as_view()),
    url(r'^api/v1/users/site_manager/', SiteManagerView.as_view()),
    #    url(r'^api/v1/encrypt/generate/', GenerateView.as_view()),
    url(r'^api/v1/reports/$', ReportView.as_view()),
    url(r'^api/v1/reports/(?P<pk>[0-9]+)/$', ReportView.as_view()),
    url(r'^api/v1/reports/folders/$', FolderView.as_view()),
    url(r'^api/v1/reports/folders/(?P<pk>[0-9]+)/$', FolderView.as_view()),
    url(r'^api/v1/messages/inbox/$', MessageInboxView.as_view()),
    url(r'^api/v1/messages/inbox/(?P<pk>[0-9]+)/$',
        MessageInboxView.as_view()),
    url(r'^api/v1/messages/outbox/$', MessageOutboxView.as_view()),
    url(r'^api/v1/messages/outbox/(?P<pk>[0-9]+)/$',
        MessageOutboxView.as_view()),
Exemplo n.º 9
0
from report.views import ReportView, FolderView
from secureshare_messages.views import MessageInboxView, MessageSendView, MessageOutboxView, MessageDecryptView
from authentication.views import RegisterView, LoginView, LogoutView, SiteManagerView, GroupView

#router = routers.SimpleRouter()
#router.register(r'reports',ReportViewSet, base_name='Report')
#router.register(r'messages',MessageViewSet, base_name='Message')

urlpatterns = [
    # Examples:
    # url(r'^$', 'secureshare.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    #url(r'^api/v1/',include(router.urls)),

    url(r'^api/v1/users/register/',RegisterView.as_view()),
    url(r'^api/v1/users/login/',LoginView.as_view()),
    url(r'^api/v1/users/logout/',LogoutView.as_view()),
    url(r'api/v1/users/groups/',GroupView.as_view()),

    url(r'^api/v1/users/site_manager/',SiteManagerView.as_view()),
#    url(r'^api/v1/encrypt/generate/', GenerateView.as_view()),

    url(r'^api/v1/reports/$',ReportView.as_view()),
    url(r'^api/v1/reports/(?P<pk>[0-9]+)/$',ReportView.as_view()),
    url(r'^api/v1/reports/folders/$',FolderView.as_view()),
    url(r'^api/v1/reports/folders/(?P<pk>[0-9]+)/$',FolderView.as_view()),

    url(r'^api/v1/messages/inbox/$',MessageInboxView.as_view()),
    url(r'^api/v1/messages/inbox/(?P<pk>[0-9]+)/$',MessageInboxView.as_view()),
    url(r'^api/v1/messages/outbox/$',MessageOutboxView.as_view()),
Exemplo n.º 10
0
from django.urls import path
from authentication.views import SignupPageView, RegisterView, LoginView

urlpatterns = [
    path('signup/', SignupPageView.as_view(), name='signup'),
    path('register', RegisterView.as_view(), name='register_view'),
    path('login', LoginView.as_view()),
]
Exemplo n.º 11
0
Including another URLconf
    1. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import include, url
from django.contrib import admin
from authentication.views import RegisterView, LoginView, logout_view
from feed.views import feed_view, feed_by_rating_view
from userinfo.views import profile_view, settings_view, UserInfoView, status_view
from posts.views import choose_template_view, create_post_view, post_view, edit_post_view, ApiPostView, all_tags_view
from comments.views import CommentView, delete_comment
from search.views import search_view

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^login$', LoginView.as_view(), name='login'),
    url(r'^register$', RegisterView.as_view(), name='register'),
    url(r'^logout$', logout_view, name='logout'),
    url(r'^settings$', settings_view, name='settings'),
    url(r'^user_status$', status_view, name='status'),
    url(r'^userinfo$', UserInfoView.as_view(), name='userinfo'),
    url(r'^profile/(?P<username>.+)$', profile_view, name='detail'),
    url(r'^posts/create/choose_template$', choose_template_view, name='choose_template'),
    url(r'^posts/create/(?P<template_name>.+)$', create_post_view, name='create_post'),
    url(r'^posts/edit/(?P<id>.+)$', edit_post_view, name='edit_post'),
    url(r'^posts/(?P<id>.+)$', post_view, name='post'),
    url(r'tags$', all_tags_view, name='all_tags'),
    url(r'^api/posts/comments/(?P<post_id>.+)$', CommentView.as_view(), name='comments_by_post'),
    url(r'^api/comments/(?P<id>.+)$', delete_comment, name='delete_comment'),
    url(r'^api/posts/(?P<id>.+)$', ApiPostView.as_view(), name='post_api'),
    url('', include('social.apps.django_app.urls', namespace='social')),
    url(r'^ratings/', include('star_ratings.urls', namespace='ratings', app_name='ratings')),
Exemplo n.º 12
0
from django.conf.urls import url

from authentication.views import LoginView, RegisterView


urlpatterns = [
    url(r'^login$', LoginView.as_view(), name='login'),
    url(r'^register$', RegisterView.as_view(), name='register'),
]
Exemplo n.º 13
0
'''
Created on Dec 11, 2013
'''
from django.conf.urls import patterns, url
from authentication.views import RegisterView, LoginView, logout_user,\
    authenticated_page

urlpatterns = patterns('',
                       url(r'^register$', RegisterView.as_view(), name='authentication_register'),
                       url(r'^login$', LoginView.as_view(), name='authentication_login'),
                       url(r'^logout_user$', logout_user, name='authentication_logout_user'),
                       url(r'^authenticated_page$', authenticated_page, name='authentication_authenticated_page'),
                       )
Exemplo n.º 14
0
The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.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.contrib.auth.views import login, logout
from django.urls import include, path
from authentication.views import RegisterView
from django.conf.urls import url
from django.views.generic import TemplateView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('register/', RegisterView.as_view()),
    path('login/', login, {'template_name': 'login.html'}),
    path('logout/', logout, {'next_page': '/'}),
    path('api/', include('editor.urls')),
    path('', TemplateView.as_view(template_name="home.html")),
    url(r'^', TemplateView.as_view(template_name="index.html")),
]