Python django.contrib.auth.forms.PasswordResetForm() Examples
The following are 7
code examples of django.contrib.auth.forms.PasswordResetForm().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.contrib.auth.forms
, or try the search function
.

Example #1
Source File: views.py From canvas with BSD 3-Clause "New" or "Revised" License | 7 votes |
def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html', domain_override='example.com', email_template_name='registration/password_reset_email.html', password_reset_form=PasswordResetForm, token_generator=default_token_generator, post_reset_redirect=None): if post_reset_redirect is None: post_reset_redirect = reverse('drawquest.apps.drawquest_auth.views.password_reset_done') if request.method == "POST": form = password_reset_form(request.POST) if form.is_valid(): opts = {} opts['use_https'] = request.is_secure() opts['token_generator'] = token_generator opts['email_template_name'] = email_template_name opts['request'] = request if domain_override: opts['domain_override'] = domain_override if is_admin_site: opts['domain_override'] = request.META['HTTP_HOST'] form.save(**opts) return HttpResponseRedirect(post_reset_redirect) else: form = password_reset_form() return r2r_jinja(template_name, {'form': form}, request)
Example #2
Source File: import_shad_users.py From anytask with MIT License | 6 votes |
def handle_noargs(self, **options): # user = User.objects.get(pk=1) group = Group.objects.get(pk=2) # group.students.add(user) for student in sys.stdin: fields = student.strip().split(' ') email = fields[0] # print email, len(fields) if len(fields) > 3: continue username = email.split('@')[0] last_name = fields[1] first_name = fields[2] print email, username, last_name, first_name user, created = User.objects.get_or_create(username=username, first_name=first_name, last_name=last_name, email=email) group.students.add(user) reset_form = PasswordResetForm({'email': email}) print reset_form reset_form.save() group.save()
Example #3
Source File: forms.py From zentral with Apache License 2.0 | 5 votes |
def save(self, request): user = super(AddUserForm, self).save(commit=False) user.set_password(get_random_string(1024)) user.save() prf = PasswordResetForm({"email": user.email}) if prf.is_valid(): prf.save(request=request, use_https=True, email_template_name='registration/invitation_email.html', subject_template_name='registration/invitation_subject.txt') return user
Example #4
Source File: schema.py From django-graph-auth with MIT License | 5 votes |
def mutate_and_get_payload(cls, input, context, info): if graph_auth_settings.CUSTOM_PASSWORD_RESET_TEMPLATE is not None and graph_auth_settings.EMAIL_FROM is not None and graph_auth_settings.PASSWORD_RESET_URL_TEMPLATE is not None: from mail_templated import EmailMessage for user in UserModel.objects.filter(email=input.get('email')): uid = urlsafe_base64_encode(force_bytes(user.pk)).decode() token = token_generator.make_token(user) link = graph_auth_settings.PASSWORD_RESET_URL_TEMPLATE.format(token=token, uid=uid) input_data = { "email": user.email, "first_name": user.first_name, "last_name": user.last_name, "link": link } message = EmailMessage(graph_auth_settings.CUSTOM_PASSWORD_RESET_TEMPLATE, input_data, graph_auth_settings.EMAIL_FROM, [user.email]) message.send() else: data = { 'email': input.get('email'), } reset_form = PasswordResetForm(data=data) if not reset_form.is_valid(): raise Exception("The email is not valid") options = { 'use_https': context.is_secure(), 'from_email': getattr(settings, 'DEFAULT_FROM_EMAIL'), 'request': context } reset_form.save(**options) return ResetPasswordRequest(ok=True)
Example #5
Source File: serializers.py From django-rest-auth with MIT License | 5 votes |
def validate_email(self, value): # Create PasswordResetForm with the serializer self.reset_form = self.password_reset_form_class(data=self.initial_data) if not self.reset_form.is_valid(): raise serializers.ValidationError(self.reset_form.errors) return value
Example #6
Source File: views.py From YaraGuardian with Apache License 2.0 | 5 votes |
def form_valid(self, form): form.register_user() email = form.cleaned_data['email'] password_reset = PasswordResetForm({'email': email}) if password_reset.is_valid(): password_reset.save(request=self.request) return super(RegisterAccount, self).form_valid(form)
Example #7
Source File: test_view_password_reset.py From django-beginners-guide with MIT License | 5 votes |
def test_contains_form(self): form = self.response.context.get('form') self.assertIsInstance(form, PasswordResetForm)