Esempio n. 1
0
def activate_user(request, user, token):
    try:
        uid = force_text(urlsafe_base64_decode(user))
        user = User.objects.get(pk=uid)

        activation_view = ActivationView()
        activation_view.validate_key(token)

        user.is_active = True
        user.save()

        # send an email that the account has been activated
        email_settings = {
            'template':
            'emails/general-email.html',
            'subject':
            '[%s] Account Activated' % settings.SITE_NAME,
            'sender_email':
            settings.SENDER_EMAIL,
            'recipient_email':
            user.email,
            'use_queue':
            getattr(settings, 'QUEUE_EMAILS', False),
            'title':
            'Account Activated',
            'message':
            'Thank you for confirming your email. Your account at %s is now active.'
            % settings.SITE_NAME,
        }
        notify = Notification()
        notify.send_email(email_settings)

        uid = urlsafe_base64_encode(force_bytes(user.email))
        return HttpResponseRedirect('/new_user_password/%s/%s' % (uid, token))

    except ActivationError as e:
        if settings.DEBUG: terminal.tprint(str(e), 'fail')
        capture_exception(e)
        return reverse('home', kwargs={'error': True, 'message': e.message})

    except User.DoesNotExist as e:
        if settings.DEBUG: terminal.tprint(str(e), 'fail')
        capture_exception(e)
        return reverse('home',
                       kwargs={
                           'error': True,
                           'message': 'The specified user doesnt exist'
                       })

    except Exception as e:
        if settings.DEBUG: terminal.tprint(str(e), 'fail')
        capture_exception(e)
        return reverse(
            'home',
            kwargs={
                'error':
                True,
                'message':
                'There was an error while activating your account. Contact the system administrator'
            })
Esempio n. 2
0
    def mutate(cls, _, info, **kwargs):
        key = kwargs.pop('key')

        try:
            user = ActivationView().activate(activation_key=key)
        except ActivationError as e:
            raise ValueError(e.message)

        token = get_token(user, info.context)
        payload = get_payload(token, info.context)

        user_activated.send(sender=User, user=user, request=info.context)

        return cls(user=user, token=token, payload=payload)
Esempio n. 3
0
     'accounts/register/',
     RegistrationView.as_view(
         form_class=user_forms.CustomRegistrationForm,
     ),
     name='django_registration_register',
 ),
 path(
     'accounts/activate/complete/',
     TemplateView.as_view(
         template_name='django_registration/activation_complete.html'
     ),
     name='django_registration_activation_complete',
 ),
 path(
     'accounts/activate/<str:activation_key>/',
     ActivationView.as_view(),
     name='django_registration_activate',
 ),
 path('accounts/', include('django_registration.backends.activation.urls')),
 path('accounts/', include('django.contrib.auth.urls')),
 path(
     'channel/',
     channel_manager_views.IndexView.as_view(),
     name='channel-manager-index',
 ),
 path(
     'channel/index-blank',
     channel_manager_views.IndexBlankView.as_view(),
     name='channel-manager-index-blank',
 ),
 path(
Esempio n. 4
0
         PasswordChangeView.as_view(),
         name='password_change'),
    # password reset
    path('password_reset/', PasswordResetView.as_view(),
         name='password_reset'),
    path('reset/<uidb64>/<token>/',
         PasswordResetConfirmView.as_view(),
         name='password_reset_confirm'),
    path('reset/done/',
         PasswordResetCompleteView.as_view(),
         name='password_reset_complete'),

    # register
    path('register/',
         RegistrationView.as_view(),
         name='django_registration_register'),
    path('register/closed/',
         TemplateView.as_view(
             template_name="django_registration/registration_closed.html"),
         name='django_registration_disallowed'),
    path('activate/complete/',
         TemplateView.as_view(
             template_name="django_registration/activation_complete.html"),
         name='django_registration_activation_complete'),
    path('activate/<str:activation_key>/',
         ActivationView.as_view(success_url=reverse_lazy(
             "user:django_registration_activation_complete")),
         name='django_registration_activate'),
    path('profile/', UserUpdateView.as_view(), name='profile'),
]
Esempio n. 5
0
    path('reset/done/', auth_views.PasswordResetCompleteView.as_view(), 
         name='password_reset_complete'),
]

# django_registration
urlpatterns += [
    path(
        "activate/complete/",
        TemplateView.as_view(
            template_name="django_registration/activation_complete.html"
        ),
        name="activation_complete",
    ),
    path(
        "activate/<str:activation_key>/",
        ActivationView.as_view(success_url=reverse_lazy("feniceauth:activation_complete")), # django_registration/activation_failed.html
        name="activate",
    ),
    path(
        "register/",
        RegistrationView.as_view(
            form_class=FeniceRegistrationForm,
            success_url=reverse_lazy("feniceauth:complete"),
            disallowed_url=reverse_lazy("feniceauth:disallowed")
        ), # django_registration/registration_form.html
        name="register",
    ),
    path(
        "register/complete/",
        TemplateView.as_view(
            template_name="django_registration/registration_complete.html"
Esempio n. 6
0
from django.urls import path, reverse_lazy
from accounts import views
from django_registration.backends.activation.views import RegistrationView, ActivationView
from django.contrib.auth import views as auth_views

app_name = 'accounts'

urlpatterns = [
    path('register/',
         RegistrationView.as_view(success_url=reverse_lazy('accounts:login')),
         name='register'),
    path(
        'activate/<str:activation_key>/',
        ActivationView.as_view(success_url=reverse_lazy('accounts:login')),
        name="activate",
    ),
    path('login/', auth_views.LoginView.as_view(), name='login'),
    path('logout/', auth_views.LogoutView.as_view(), name='logout'),
    path('profile/edit/', views.edit_profile_view, name='edit'),
    path('profile/my/', views.my_profile_view, name='my_profile'),
    path('profile/<str:username>/', views.profile_view, name='profile'),
]
Esempio n. 7
0
from django.conf.urls.static import static
app_name='accounts'

urlpatterns=[
    path('login/', auth_views.LoginView.as_view(template_name = 'accounts/login.html'),
        name='login'),
    path('password_reset/', auth_views.PasswordResetView.as_view(template_name='accounts/password_reset_form.html'),
        name='password_reset'),
    path('password_reset/done/', auth_views.PasswordResetDoneView.as_view(template_name='accounts/password_reset_done.html'),
        name='password_reset_done'),
    path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(template_name='accounts/password_reset_confirm.html'),
        name='password_reset_confirm'),
    path('reset/done/', auth_views.PasswordResetCompleteView.as_view(template_name='accounts/password_reset_complete.html'),
        name='password_reset_complete'),
    path('password_change', auth_views.PasswordChangeView.as_view(template_name='accounts/password_change_form.html'),
        name='password_change'),
    path('password_change/done/', auth_views.PasswordChangeDoneView.as_view(template_name='accounts/password_change_done.html'),
        name='password_change_done'),
    path('registration_form/', SignUpView.as_view(),name='django_registration_register'),
    path('register/complete/', TemplateView.as_view(template_name='accounts/registration_complete.html'),
        name='django_registration_complete'),
    path('registration_disallowed/', TemplateView.as_view(template_name='accounts/registration_disallowed.html'),
        name='django_registration_disallowed'),
    path('activate/complete/', TemplateView.as_view(template_name='accounts/activation_complete.html'),
        name='django_registration_activation_complete'),
    path('activate/<activation_key>/', ActivationView.as_view(template_name='accounts/activation_failed.html'),
        name='django_registration_activate'),
    path('profile/', ProfileDetailView, name='profile'),
    path('update_profile/', ProfileEditView, name='update_profile'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Esempio n. 8
0
    path('password-reset/done/',
         PasswordResetDoneView.as_view(),
         name='password_reset_done'),
    path('reset/<uidb64>/<token>/',
         PasswordResetConfirmView.as_view(),
         name='password_reset_confirm'),
    path('reset/done/',
         PasswordResetCompleteView.as_view(),
         name='password_reset_complete'),
    path('register/',
         RegistrationView.as_view(
             success_url='/',
             form_class=CustomUserCreationForm,
             template_name='registration/registration_form.html',
             email_body_template='registration/activation_email.txt',
             email_subject_template='registration/activation_email_subject.txt'
         ),
         name='django_registration_register'),
    path(
        'activate/complete/',
        TemplateView.as_view(
            template_name="registration/activation_complete.html"),
        name="django_registration_activation_complete",
    ),
    path('activate/<str:activation_key>/',
         ActivationView.as_view(
             template_name='registration/activation_failed.html'),
         name="django_registration_activate"),
    path('', include('social_django.urls', namespace='social'))
]
Esempio n. 9
0
File: urls.py Progetto: jomibg/Nutri
         ProfileUpdate.as_view(success_url=reverse_lazy('home')),
         name='ch_info'),
    path('change_password/',
         av.PasswordChangeView.as_view(success_url=reverse_lazy('home'),
                                       form_class=FormaPromena),
         name='password_change'),
    ###########Registration################################
    path('register/',
         redirect_authenticated(
             RegistrationView.as_view(
                 form_class=FormaRegistracija,
                 success_url=reverse_lazy('accounts:successfull'),
                 disallowed_url=reverse_lazy('accounts:disallowed'))),
         name='register'),
    path('disallowed/',
         TemplateView.as_view(
             template_name='django_registration/disallowed.html'),
         name='disallowed'),
    path('successfull/',
         TemplateView.as_view(
             template_name='django_registration/successfull.html'),
         name='successfull'),
    path("activate/<str:activation_key>/",
         ActivationView.as_view(success_url=reverse_lazy('accounts:complete')),
         name="django_registration_activate"),
    path('activate/complete',
         TemplateView.as_view(
             template_name='django_registration/complete.html'),
         name='complete')
]
Esempio n. 10
0
        name="password_change_done"
    ),

    # Registration
    url(
        r'^activate/complete/$',
        mps.views.TemplateView.as_view(
            template_name='django_registration/activation_complete.html'
        ),
        name='django_registration_activation_complete'
    ),
    # The activation key can make use of any character from the
    # URL-safe base64 alphabet, plus the colon as a separator.
    url(
        r'^activate/(?P<activation_key>[-:\w]+)/$',
        ActivationView.as_view(),
        name='django_registration_activate'
    ),
    url(
        r'^register/$',
        RegistrationView.as_view(
            form_class=mps.forms.CaptchaRegistrationForm
        ),
        name='django_registration_register'
    ),
    url(
        r'^register/complete/$',
        mps.views.TemplateView.as_view(
            template_name='django_registration/registration_complete.html'
        ),
        name='django_registration_complete'