def save_model(self, request, obj, form, change): obj.role = 'admin' super(UserDisp, self).save_model(request, obj, form, change) request.POST = { 'email': obj.email, 'csrfmiddlewaretoken': get_token(HttpRequest()) } PasswordResetView.as_view()(request)
def send_email_to_user(self, user): request = HttpRequest() request.method = 'POST' if settings.DEBUG: request.META['HTTP_HOST'] = 'localhost:8000' else: request.META['HTTP_HOST'] = settings.BACKEND_BASE_URL request.POST = { 'email': user.email, 'csrfmiddlewaretoken': get_token(HttpRequest()) } PasswordResetView.as_view()(request)
def post(self, request): email = request.data.get('email') request = HttpRequest() request.method = 'POST' print(request.get_full_path()) # add the absolute url to be be included in email if settings.DEBUG: request.META['HTTP_HOST'] = '127.0.0.1:8000' else: request.META['HTTP_HOST'] = 'severstar-backend.herokuapp.com' # pass the post form data request.POST = { 'email': email, 'csrfmiddlewaretoken': get_token(HttpRequest()) } PasswordResetView.as_view()(request) return Response({"response": "reset link has been send to email.."})
def send_reset_password_email(sender, instance, created, **kwargs): if created: # First create a post request to pass to the view request = HttpRequest() request.method = 'POST' # add the absolute url to be be included in email site = Site.objects.get(id=settings.SITE_ID).domain request.META['HTTP_HOST'] = site # pass the post form data request.POST = { 'email': instance.email, 'csrfmiddlewaretoken': get_token(HttpRequest()) } PasswordResetView.as_view()(request)
def send_reset_password_email(sender, instance, created, **kwargs): if created: request = HttpRequest() request.method = 'POST' if settings.DEBUG: request.META['HTTP_HOST'] = '127.0.0.1:8000' else: request.META['HTTP_HOST'] = '' # pass the post form data request.POST = { 'email': instance.email, 'csrfmiddlewaretoken': get_token(HttpRequest()) } PasswordResetView.as_view()(request) # email will be sent!
def send_reset_password_email(sender, instance, created, **kwargs): if created: # First create a post request to pass to the view request = HttpRequest() request.method = 'POST' # add the absolute url to be be included in email if settings.DEBUG: request.META['HTTP_HOST'] = '127.0.0.1:8000' else: request.META['HTTP_HOST'] = 'www.mysite.com' # pass the post form data request.POST = { 'email': instance.email, 'csrfmiddlewaretoken': get_token(HttpRequest()) } PasswordResetView.as_view()(request) # email will be sent!
def handle(self, *args, **options): try: if options['donorids']: # operate on specific users, beware it is a list of lists donorids_list = [ item for sublist in options['donorids'] for item in sublist ] donors = User.objects.filter(pk__in=donorids_list) else: # operate on all users donors = User.objects.all() # Create a post request to pass to the view request = HttpRequest() request.method = 'POST' # add the absolute url to be be included in email if options['site_host']: request.META['HTTP_HOST'] = options['site_host'] else: newstreamSite = Site.objects.filter(is_default_site=True).get() request.META['HTTP_HOST'] = newstreamSite.hostname # loop donors to send email to each one for donor in donors: # pass the post form data request.POST = { 'email': donor.email, 'csrfmiddlewaretoken': get_token(HttpRequest()) } PasswordResetView.as_view()(request) # email will be sent! self.print("[√] PasswordReset Email sent to %s(%d)" % (donor.fullname, donor.id)) except Exception as e: self.print(str(e)) traceback.print_exc()
# url(r'^password-reset/confirm/(?P<uidb64>[-\w]+)/(?P<token>[-\w]+)/$', DjangoPasswordResetConfirmView.as_view(form_class=UserSetPasswordForm, success_url=reverse_lazy('appaccounts:password_reset_complete')), name='password_reset_confirm'), # url(r'^password-reset/complete/$', DjangoPasswordResetCompleteView.as_view(), name='password_reset_complete'), ################### # Auth urls by AllAuth ################### # register urls url(r'^register/$', SignupView.as_view(form_class=AllAuthSignupForm, template_name='appaccounts/register.html'), name='register'), # password reset url(r'^password/reset/$', AllAuthPasswordResetView.as_view(form_class=AllAuthResetPasswordForm), name="password_reset"), url(r'^password/reset/done/$', AllAuthPasswordResetDoneView.as_view(), name="account_reset_password_done"), # url(r'^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$', AllAuthPasswordResetFromKeyView.as_view(form_class=AllAuthResetPasswordKeyForm), name="account_reset_password_from_key"), url(r'^password/reset/key/done/$', AllAuthPasswordResetFromKeyDoneView, name="account_reset_password_from_key_done"), # Login url(r'^login/$', LoginView.as_view(form_class=AllAuthLoginForm, template_name='registration/login.html'), name='login'), # url(r'^logout/$', login_required(LogoutView.as_view()), name='logout'),
SignalCreateAPI.as_view(), name='signal-create-api'), path('api/signal-update/<int:pk>/', SignalUpdateAPI.as_view(), name='signal-update-api'), path('api/condition-create/', ConditionCreateAPI.as_view(), name='condition-create-api'), path('api/coin-detail/<slug:slug>/', CoinDetailAPI.as_view(), name='coin-detial-api'), path('login/', LoginView.as_view(), name='account_login'), path('logout/', LogoutView.as_view(), name='account_logout'), path('signup/', SignupView.as_view(), name='account_signup'), path('reset-password/', PasswordResetView.as_view(), name='account_reset_password'), path('confirm-email/(?P<key>[-:\w]+)/', confirm_email, name='account_confirm_email'), # password reset path('password/reset/', password_reset, name='account_reset_password'), path('password/reset/done/', password_reset_done, name='account_reset_password_done'), path('password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/', password_reset_from_key, name='account_reset_password_from_key'), path('password/reset/key/done/', password_reset_from_key_done,
from django.urls import path, include from . import views as auction_views from allauth.account.views import LoginView, LogoutView, PasswordResetView urlpatterns = [ path('', auction_views.home, name='index'), path('register/', auction_views.register, name='register'), path('login/', LoginView.as_view(template_name='auction/login.html'), name='login'), path('logout/', LogoutView.as_view(template_name='auction/logout.html'), name='logout'), path( 'password_reset/', PasswordResetView.as_view(template_name='auction/password_reset.html'), name='reset_password'), path('team/<str:pk>/', auction_views.TeamDetailView.as_view(), name='team-detail'), path('team/<str:pk>/edit', auction_views.updateTeamView.as_view(), name='team-edit'), # path('team/list', # auction_views.TeamLineUpListView.as_view(), name='lineup'), path('auctions/list', auction_views.AuctionListView.as_view(), name='auction-list'), path('auctions/new', auction_views.AuctionCreateView.as_view(), name='auction-new'),
), path( "users/login", logged_users_redirect( LoginView.as_view(template_name="registration/login.html")), name="account_login", ), path( "users/logout", LogoutView.as_view(template_name="registration/logout.html"), name="account_logout", ), path( "users/reset", logged_users_redirect( PasswordResetView.as_view( template_name="registration/password_reset_form.html")), name="account_reset_password", ), url( r"^users/password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$", logged_users_redirect( PasswordResetFromKeyView.as_view( template_name="registration/password_reset_confirm.html")), name="account_reset_password_from_key", ), path( "users/reset/key/done", logged_users_redirect( PasswordResetFromKeyDoneView.as_view( template_name="registration/password_reset_complete.html")), name="account_reset_password_from_key_done",
views.userProfileProfile, name='profileProfile'), url(r'^profile/menteelogin.html', views.userProfile, name='profile'), url(r'^profile/feedback/feedback_contact.html', views.feedback_process, name='feedback_process'), url(r'^profile/contact_form/contact_form.html', include('contact_form.urls')), #url(r'^profile/contact_form/sent/', include('contact_form.urls')), url(r'^profile/settings.html', views.userProfileSettings, name='profileSettings'), #url(r'^profile/contact', include('feedback.urls')), url(r'^profile/feedback/form-to-email.php', views.feedback_process), url(r'^accounts/password/reset', PasswordResetView.as_view(template_name='password_reset.html')), url(r'^accounts/', include('allauth.urls')), url(r'^content/', include('content.urls')), url(r'^feedback/', include('feedback.urls')), url(r'', include('blog.urls')), url(r'^contact/sent/$', TemplateView.as_view( template_name='contact_form/contact_form_sent.html'), name='contact_form_sent'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from allauth.account.forms import LoginForm, ResetPasswordForm from allauth.account.views import LoginView, PasswordResetView from captcha.fields import ReCaptchaField from captcha.widgets import ReCaptchaV2Invisible class CaptchaResetPasswordForm(ResetPasswordForm): captcha = ReCaptchaField(widget=ReCaptchaV2Invisible, label="") password_reset_view = PasswordResetView.as_view( form_class=CaptchaResetPasswordForm) class CaptchaLoginForm(LoginForm): captcha = ReCaptchaField(widget=ReCaptchaV2Invisible, label="") login_view = LoginView.as_view(form_class=CaptchaLoginForm)
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, include, re_path from django.conf.urls import url from .views import FacebookLogin, GoogleLogin, LinkedInLogin, AccountConfirmed from allauth.account.views import ConfirmEmailView,PasswordResetView from rest_auth.registration.views import VerifyEmailView urlpatterns = [ path('users/', include('users.urls')), path('accounts/', include('allauth.urls')), url(r'^rest-auth/', include('rest_auth.urls')), url(r'^rest-auth/facebook/$', FacebookLogin.as_view(), name='facebook_login'), url(r'^rest-auth/google/$', GoogleLogin.as_view(), name='google_login'), url(r'^rest-auth/linkedin/$', LinkedInLogin.as_view(), name='linkedin_login'), url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-_:\w]+)/$', ConfirmEmailView.as_view(), name='account_confirm_email'), url(r'^rest-auth/registration/account-confirmed/', AccountConfirmed, name='account_confirmed'), url(r'^rest-auth/registration/', include('rest_auth.registration.urls')), url(r'^rest-auth/password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', PasswordResetView.as_view(), name='password_reset_confirm'), re_path(r'^account-confirm-email/(?P<key>[-:\w]+)/$', VerifyEmailView.as_view(), name='account_confirm_email'), path('admin/', admin.site.urls), ]
logged_users_redirect = user_passes_test(lambda u: u.is_anonymous, "/") urlpatterns = [ path("", include("app.urls")), path("api-v1/", include(router.urls)), path("api-auth/", include("rest_auth.urls")), path("api-auth/registration/", include("rest_auth.registration.urls")), # path("signup/", SignupView.as_view(), name="account_signup"), path("login/", logged_users_redirect(LoginView.as_view()), name="account_login"), path("logout/", LogoutView.as_view(), name="account_logout"), path( "password/reset/", logged_users_redirect(PasswordResetView.as_view()), name="account_reset_password", ), url( r"^users/password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$", logged_users_redirect(PasswordResetFromKeyView.as_view()), name="account_reset_password_from_key", ), path( "password/reset/key/done/", logged_users_redirect(PasswordResetFromKeyDoneView.as_view()), name="account_reset_password_from_key_done", ), path( "password/reset/done/", logged_users_redirect(PasswordResetDoneView.as_view()),