예제 #1
0
    def test_get_success_url(self, reverse_mock: MagicMock):
        # Given a mock that returns a sentinel url
        reverse_mock.return_value = sentinel.url

        view = ChangePasswordView()
        view.request = Mock(session=dict())
        view.request.user = Mock(username=sentinel.username)

        # When getting the success url
        url = view.get_success_url()

        # Then the sentinel is return, after the mock is called correctly
        assert url == sentinel.url
        reverse_mock.assert_called_once_with('users:user_settings',
                                             args=[sentinel.username])
예제 #2
0
from users.views import MyTokenObtainPairView, CurrentUsersDetailView, CreateBasicUserView, \
    UsersDetailView, ActivateUserView, RequestResetPasswordView, \
    ResetPasswordView, ChangePasswordView
app_name = 'users'
urlpatterns = [
    path('', UsersDetailView.as_view(), name='list_all_users_details'),
    path('token/', MyTokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('token/refresh/',
         jwt_views.TokenRefreshView.as_view(),
         name='token_refresh'),
    path('token/verify/',
         jwt_views.TokenVerifyView.as_view(),
         name='token_verify'),
    path('current/',
         CurrentUsersDetailView.as_view(),
         name='current_user_detail'),
    path('create-basic/',
         CreateBasicUserView.as_view(),
         name='create_basic_user'),
    path('activate/', ActivateUserView.as_view(), name='activate_user'),
    path("request-password-reset/",
         RequestResetPasswordView.as_view(),
         name="request_password_reset"),
    path("reset-password/", ResetPasswordView.as_view(),
         name="reset_password"),
    path("change-password/",
         ChangePasswordView.as_view(),
         name="change_password"),
]
예제 #3
0
    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.urls import url
from django.conf import settings
from django.conf.urls.static import static

from django.contrib.auth import views as auth_views
from users.views import CustomLoginView, PasswordResetView, ChangePasswordView
from users.forms import LoginForm

urlpatterns = [
    # Add this path
    path('admin/', admin.site.urls),
    path('', include('users.urls')),

    url(r'^oauth/', include('social_django.urls', namespace='social')),

    path('login/', CustomLoginView.as_view(redirect_authenticated_user=True, template_name='users/login.html',
                                           authentication_form=LoginForm), name='login'),
    path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'),

    path('password-reset/', PasswordResetView.as_view(), name='password_reset'),
    path('password-reset-confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'), name='password_reset_confirm'),
    path('password-reset-complete/', auth_views.PasswordResetCompleteView.as_view(template_name='users/password_reset_complete.html'), name='password_reset_complete'),
    path('password-change/', ChangePasswordView.as_view(), name='password-change'),

] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
예제 #4
0
from django.urls import path
from users.views import UserRegistrationAPIView, UserLoginAPIView, UserTokenAPIView, UserListAPIView, ChangePasswordView

urlpatterns = [
    path('register/', UserRegistrationAPIView.as_view(), name="register"),
    path('login/', UserLoginAPIView.as_view(), name="login"),
    path('list/', UserListAPIView.as_view(), name="list"),
    path('change_password/', ChangePasswordView.as_view(), name='change_password'),
    path('tokens/<key>/', UserTokenAPIView.as_view(), name="token"),
]
예제 #5
0
# -*- coding:utf-8 -*-
# edit by fuzongfei
from django.contrib.auth.decorators import login_required
from django.urls import path

from users.views import LoginView, UserProfileView, LogoutView, ChangePasswordView, ChangeMobileView, ChangePicView, \
    GetUserMailView, VerifyView

urlpatterns = [
    path('login/', LoginView.as_view(), name='p_login'),
    path('verify', VerifyView.as_view(), name='p_verify'),
    path(r'logout/', login_required(LogoutView.as_view()), name='p_logout'),
    path(r'profile/', login_required(UserProfileView.as_view()), name='p_user_profile'),
    path(r'change_password/', login_required(ChangePasswordView.as_view()), name='p_change_password'),
    path(r'change_mobile/', login_required(ChangeMobileView.as_view()), name='p_change_mobile'),
    path(r'change_picture/', login_required(ChangePicView.as_view()), name='p_change_picture'),
    # 获取用户名和邮箱
    path(r'get_usermail/', login_required(GetUserMailView.as_view()), name='p_get_user_mail'),
]
예제 #6
0
# -*- coding:utf-8 -*-
# edit by fuzongfei
from django.contrib.auth.decorators import login_required
from django.urls import path

from users.views import LoginView, UserProfileView, LogoutView, VerifyCodeView, ChangePasswordView, ChangeMobileView, \
    ChangePicView, GetEmailCcView, GetAuditorView

urlpatterns = [
    path('login/', LoginView.as_view(), name='p_login'),
    path('verify', VerifyCodeView.as_view(), name='p_verifycode'),
    path('logout/', login_required(LogoutView.as_view()), name='p_logout'),
    path('profile/',
         login_required(UserProfileView.as_view()),
         name='p_profile'),
    path('change_password/',
         login_required(ChangePasswordView.as_view()),
         name='p_change_password'),
    path('change_mobile/',
         login_required(ChangeMobileView.as_view()),
         name='p_change_mobile'),
    path('change_picture/',
         login_required(ChangePicView.as_view()),
         name='p_change_picture'),
    path('get_email_cc/', login_required(GetEmailCcView.as_view())),
    path('get_auditor/', login_required(GetAuditorView.as_view())),
]