当前位置: 首页>>代码示例>>Python>>正文


Python forms.PasswordResetForm方法代码示例

本文整理汇总了Python中django.contrib.auth.forms.PasswordResetForm方法的典型用法代码示例。如果您正苦于以下问题:Python forms.PasswordResetForm方法的具体用法?Python forms.PasswordResetForm怎么用?Python forms.PasswordResetForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.auth.forms的用法示例。


在下文中一共展示了forms.PasswordResetForm方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_noargs

# 需要导入模块: from django.contrib.auth import forms [as 别名]
# 或者: from django.contrib.auth.forms import PasswordResetForm [as 别名]
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() 
开发者ID:znick,项目名称:anytask,代码行数:27,代码来源:import_shad_users.py

示例2: password_reset

# 需要导入模块: from django.contrib.auth import forms [as 别名]
# 或者: from django.contrib.auth.forms import PasswordResetForm [as 别名]
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) 
开发者ID:canvasnetworks,项目名称:canvas,代码行数:26,代码来源:views.py

示例3: save

# 需要导入模块: from django.contrib.auth import forms [as 别名]
# 或者: from django.contrib.auth.forms import PasswordResetForm [as 别名]
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 
开发者ID:zentralopensource,项目名称:zentral,代码行数:12,代码来源:forms.py

示例4: mutate_and_get_payload

# 需要导入模块: from django.contrib.auth import forms [as 别名]
# 或者: from django.contrib.auth.forms import PasswordResetForm [as 别名]
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) 
开发者ID:morgante,项目名称:django-graph-auth,代码行数:39,代码来源:schema.py

示例5: validate_email

# 需要导入模块: from django.contrib.auth import forms [as 别名]
# 或者: from django.contrib.auth.forms import PasswordResetForm [as 别名]
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 
开发者ID:Tivix,项目名称:django-rest-auth,代码行数:9,代码来源:serializers.py

示例6: form_valid

# 需要导入模块: from django.contrib.auth import forms [as 别名]
# 或者: from django.contrib.auth.forms import PasswordResetForm [as 别名]
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) 
开发者ID:PUNCH-Cyber,项目名称:YaraGuardian,代码行数:11,代码来源:views.py

示例7: test_contains_form

# 需要导入模块: from django.contrib.auth import forms [as 别名]
# 或者: from django.contrib.auth.forms import PasswordResetForm [as 别名]
def test_contains_form(self):
        form = self.response.context.get('form')
        self.assertIsInstance(form, PasswordResetForm) 
开发者ID:sibtc,项目名称:django-beginners-guide,代码行数:5,代码来源:test_view_password_reset.py


注:本文中的django.contrib.auth.forms.PasswordResetForm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。