示例#1
0
def myktjPassword(request):
    user = request.user
    if request.method == 'POST':
        u = request.user
        oldpwd = request.POST['old_password']
        newpwd1 = request.POST['new_password1']
        newpwd2 = request.POST['new_password2']
        if (newpwd1 == newpwd2):
            if len(newpwd1) >= 6 and len(newpwd2) >= 6:
                if authenticate(username=u.username, password=oldpwd):
                    print "Trying my luck!"
                    password_change(
                        request=request,
                        post_change_redirect='/accounts/myktjpass_change')
                    print "Lucky!"
                    errorMsg = "Password changed successfully!"
                    return HttpResponse(json.dumps(errorMsg),
                                        mimetype="application/json")
                else:
                    errorMsg = "Invalid password!"
                    return HttpResponse(json.dumps(errorMsg),
                                        mimetype="application/json")
            else:
                errorMsg = "Please enter a password of atleast 6 characters long!"
                return HttpResponse(json.dumps(errorMsg),
                                    mimetype="application/json")
        else:
            errorMsg = "Your new passwords don't match!"
            return HttpResponse(json.dumps(errorMsg),
                                mimetype="application/json")
    args = {'user': user}
    return render(request, 'myktj/myktjpassword.html', args)
示例#2
0
def password_change(request):
    if request.method == 'GET' or not request.is_ajax():
        template_response = views.password_change(request, template_name='base/password_change.html')
        return template_response
    else:
        print('ajax')
        template_response = views.password_change(request, template_name='base/password_change_partial.html')
        return template_response
示例#3
0
def rattic_change_password(request, *args, **kwargs):
    print request.user
    if request.user.has_usable_password():
        # If a user is changing their password
        return password_change(request, *args, **kwargs)
    else:
        # If a user is setting an initial password
        kwargs['password_change_form'] = SetPasswordForm
        return password_change(request, *args, **kwargs)
示例#4
0
def rattic_change_password(request, *args, **kwargs):
    print request.user
    if request.user.has_usable_password():
        # If a user is changing their password
        return password_change(request, *args, **kwargs)
    else:
        # If a user is setting an initial password
        kwargs['password_change_form'] = SetPasswordForm
        return password_change(request, *args, **kwargs)
示例#5
0
def profile(request, user_id=None):
	
    u = get_object_or_404(User, pk=request.user.id)
    if u == request.user:
        if request.method == 'POST':
            messages.success(request, 'Your password was successfully updated')
            return password_change(request, post_change_redirect=reverse('web-welcome'))
        else:
            return password_change(request, post_change_redirect=reverse('web-welcome'))
    else:
        messages.error(request, 'Sorry you do not have permission to see that user\'s profile, if you think you should please let us know.')
    return HttpResponseRedirect(request.META['HTTP_REFERER'])
示例#6
0
def tutor_password_change_view(request):
    if 'back' in request.GET:
        back = request.GET['back']
    else:
        back = reverse('news')
    return password_change(
        request, 'registration/password_change_form.html', back)
示例#7
0
def change_password(request):
    basic_context = viewb.basic_context(request)
    return password_change(request, 
                           template_name = 'hot/add_edit.html',
                           post_change_redirect = 'user_profile',
                           extra_context = basic_context)
    
示例#8
0
文件: views.py 项目: tjavsi/web
def tutor_password_change_view(request):
    if 'back' in request.GET:
        back = request.GET['back']
    else:
        back = reverse('news')
    return password_change(
        request, 'registration/password_change_form.html', back)
示例#9
0
 def dispatch(self, request, *args, **kwargs):
     if request.user.is_authenticated():
         return auth_views.password_change(request, 
                      post_change_redirect=reverse('password_change_done'),
                      extra_context=self.get_context_data())
     else:
         return redirect('front')
示例#10
0
def account_settings(request):
    return views.password_change(request,
        template_name='settings/account.html',
        post_change_redirect=reverse_lazy('account_settings_success'),
        password_change_form=AccountSettingsForm,
        extra_context={"current_user" : request.user, "page": "account"}
    )
示例#11
0
def password_change_view(request):
    from django.contrib.auth.views import password_change

    return password_change(
        request,
        template_name="volunteer/change_password.html",
        post_change_redirect="/account/password_change_done/")
示例#12
0
 def delegate_password_change_render(request,
                                     template,
                                     context=None,
                                     status=200):
     return djauth_views.password_change(request,
                                         template_name=template,
                                         extra_context=context)
示例#13
0
def password_change(request):
    """ view that renders the login """
    # If the form has been submitted...
    template_name = "accounts/password_change.jade"

    return auth_views.password_change(request, post_change_redirect="/",
                                      template_name=template_name)
示例#14
0
文件: views.py 项目: m85091081/arcane
def chgpin(request):
    if not request.user.is_authenticated():
        return redirect('home')
    return password_change(request,
                           template_name='user/chgpin.html',
                           post_change_redirect='home',
                           password_change_form=PasswordChangeForm)
示例#15
0
文件: views.py 项目: cns-iu/nwb
def change_password(request):
    redirect_url = reverse('epic.core.views.view_profile')

    return password_change(
        request,
        post_change_redirect=redirect_url,
        template_name='core/change_password.html')
示例#16
0
文件: views.py 项目: vituocgia/wshop
 def post(self, *args, **kwargs):
     response = password_change(self.request,
                                post_change_redirect="wshop:customer_edit",
                                template_name=self.template_name)
     if response.status_code == 302:
         messages.success(self.request, _("Password successfully changed."))
     return response
示例#17
0
def change_password(request):
  """ Allows the user to reset his/her password. """
  extra_context = helpers.get_extra_context(request)
  extra_context['title'] = 'Change Password'
  return views.password_change(request, template_name='reset/password-change-form.epy',
    extra_context=extra_context, post_change_redirect='done',
    password_change_form=forms.PasswordWithMinLengthChangeForm)
示例#18
0
 def password_change(self, request):
     """
     Handles the "change password" task -- both form display and validation.
     """
     from django.contrib.auth.views import password_change
     return password_change(request,
         post_change_redirect='%spassword_change/done/' % self.root_path)
示例#19
0
 def render_to_response(self, context, **response_kwargs):
     context['page_title'] = u'修改密码'
     template_response = password_change(
         self.request,
         template_name='adminlte/change-password.html',
         extra_context=context)
     return template_response
示例#20
0
def password_change(request):
    """ view that renders the login """
    # If the form has been submitted...
    template_name = "accounts/password_change.jade"

    return auth_views.password_change(request, post_change_redirect="/",
                                      template_name=template_name)
示例#21
0
文件: sites.py 项目: rawwell/django
    def password_change(self, request):
        """
        Handles the "change password" task -- both form display and validation.
        """
        from django.contrib.auth.views import password_change

        return password_change(request)
示例#22
0
def kanisa_members_password_change(request):
    return password_change(
        request,
        template_name='kanisa/management/password_reset.html',
        post_change_redirect='/members/',
        password_change_form=KanisaChangePasswordForm
    )
示例#23
0
 def password_change(self, request):
     """
     Handles the "change password" task -- both form display and validation.
     """
     from django.contrib.auth.views import password_change
     return password_change(request,
         post_change_redirect='%spassword_change/done/' % self.root_path)
示例#24
0
def main(request):
    if request.user.has_usable_password():
        return HttpResponseRedirect(reverse('password_change'))
    return password_change(request,
                           template_name='accounts/password_set.html',
                           password_change_form=SetPasswordForm,
                           post_change_redirect=reverse('password_set_done'))
示例#25
0
def password_change(request):
    return auth_views.password_change(
        request,
        template_name='accounts/password_change_form.html',
        password_change_form=PasswordChangeFormBootstrap,
        post_change_redirect=reverse('password_change_done'),
    )
示例#26
0
def password_change(request, *args, **kwargs):
    return auth_views.password_change(
        request,
        template_name="clickclick/auth/password_change.html",
        post_change_redirect='/',
        *args,
        **kwargs)
示例#27
0
def password_change_form(request):
    if request.method == 'POST':
        return password_change(request, post_change_redirect='/password_change_successful')
    else:
        return render_to_response('registration/password_change_form.html',
                                  {},
                                  context_instance = RequestContext(request))
示例#28
0
 def render_to_response(self, context, **response_kwargs):
     context.update(self.settings)
     return password_change(
         request=self.request,
         template_name=self.template_name,
         post_change_redirect=reverse_lazy('password-change-done'),
         extra_context=context)
示例#29
0
def password_change_form(request):
    if request.method == 'POST':
        return password_change(request, post_change_redirect='password_change_successful')
    else:
        return render_to_response('registration/password_change_form.html',
                                  {},
                                  context_instance = RequestContext(request))
示例#30
0
def password_change_proxy(request, *args, **kwargs):
    """ Proxies the django.contrib.auth view. Only lets a user see the form or POST to it
        if the user is not a member of an integrated portal. """
    user = request.user
    if user.is_authenticated() and check_user_integrated_portal_member(user):
        return TemplateResponse(request, 'cosinnus/registration/password_cannot_be_changed_page.html')
    return password_change(request, *args, **kwargs)
示例#31
0
def custom_password_change(request):
    """
    custom change password form
    """
    return password_change(request,
                           template_name='django_project/change_password.html',
                           extra_context={},
                           post_change_redirect="custom_password_change_done")
def password_change(request, *args, **kwargs):
    defaults = {
        'template_name': 'accounts/password_change_form.html',
        'post_change_redirect': reverse('accounts:password_change_done'),
    }
    for key, value in defaults.items():
        kwargs.setdefault(key, value)
    return auth.password_change(request, *args, **kwargs)
示例#33
0
 def post(self, request, *args, **kwargs):
     redirect_url = self.get_success_url()
     response = password_change(
         request, template_name='network_monitor/core/change_password.html',
         post_change_redirect=redirect_url)
     if response.status_code == 302 and response.url == redirect_url:
         success_message('Password changed successfully.', request)
     return response
示例#34
0
def custom_password_change(request):
    """
    custom change password form
    """
    return password_change(request,
                           template_name='django_project/change_password.html',
                           extra_context={},
                           post_change_redirect="custom_password_change_done")
示例#35
0
 def post(self, request, *args, **kwargs):
     return auth_views.password_change(
         request,
         template_name=self.template_name,
         post_change_redirect="app:password_change_done",
         password_change_form=MyPasswordChangeForm,
         current_app=None,
         extra_context=None)
示例#36
0
def password_change(request,
                   template_name='registration/password_change_form.html',
                   post_change_redirect=None,
                   password_change_form=PasswordChangeForm,
                   current_app=None, extra_context=None):
    return auth_views.password_change(request, template_name=template_name, post_change_redirect=post_change_redirect,
                                     password_change_form=password_change_form,current_app=current_app,
                                     extra_context=extra_context)
示例#37
0
文件: views.py 项目: jkatz/pgweb
def changepwd(request):
    if hasattr(request.user, 'password') and request.user.password == OAUTH_PASSWORD_STORE:
        return HttpServerError(request, "This account cannot change password as it's connected to a third party login site.")

    log.info("Initiating password change from {0}".format(get_client_ip(request)))
    return authviews.password_change(request,
                                     template_name='account/password_change.html',
                                     post_change_redirect='/account/changepwd/done/')
示例#38
0
def changepwd(request):
	if hasattr(request.user, 'password') and request.user.password == OAUTH_PASSWORD_STORE:
		return HttpServerError(request, "This account cannot change password as it's connected to a third party login site.")

	log.info("Initiating password change from {0}".format(get_client_ip(request)))
	return authviews.password_change(request,
									 template_name='account/password_change.html',
									 post_change_redirect='/account/changepwd/done/')
示例#39
0
def password_change(request):
    return auth_views.password_change(
        request,
        post_change_redirect=PASSWORD_CHANGE_REDIRECT_URL,
        extra_context=EXTRA_CONTEXT,
        password_change_form=PasswordChangeForm,
        template_name=get_full_template_name('password_change_form.html')
    )
示例#40
0
文件: views.py 项目: gurch101/shuup
 def post(self, *args, **kwargs):
     response = password_change(
         self.request,
         post_change_redirect="shuup:customer_edit",
         template_name=self.template_name
     )
     if response.status_code == 302:
         messages.success(self.request, _("Password successfully changed."))
     return response
示例#41
0
def usuario_password_change(request, slug):
    instance = tipo_perfil_usuario_mixin(request)
    return password_change(request,
                        template_name='password_change.html',
                        post_change_redirect=reverse_lazy("usuario:control"),
                        password_change_form=PasswordChangeForm,
                        extra_context={'username':request.user.username,
                                       'instance':instance}
                    )
示例#42
0
def change_password(request):
    template_name = "shoop/customer_information/change_password.jinja"

    response = password_change(request,
                               post_change_redirect="shoop:customer_edit",
                               template_name=template_name)
    if response.status_code == 302:
        messages.success(request, _("Password successfully changed."))
    return response
示例#43
0
def password_set(request):
    u"""
    Если у пользователя не задан пароль, то не нужно запрашивать его
    """
    if request.user.password and request.user.has_usable_password():
        raise Http404
    return password_change(
        request, template_name=u'authorisation/passwd_set.html',
        password_change_form=SetPasswordForm)
示例#44
0
文件: models.py 项目: ipsolar/isimip
 def change_password(self, request):
     if not request.user.is_authenticated():
         messages.info(
             request,
             'This is a restricted area. To proceed you need to log in.')
         return HttpResponseRedirect(self.reverse_subpage('login'))
     subpage = {'title': 'Change password', 'url': ''}
     context = {'page': self, 'subpage': subpage, 'headline': ''}
     return password_change(request, extra_context=context)
示例#45
0
def change_form(request):
    redir = request.GET.get('next', conf.LOGIN_REDIRECT_URL)

    return auth_views.password_change(
        request,
        template_name="accounts/password/change/form.html",
        post_change_redirect=redir,
        password_change_form=forms.PasswordChangeForm,
        extra_context=None)
示例#46
0
 def password_change(self, request):
     """
     Handles the "change password" task -- both form display and validation.
     """
     from django.contrib.auth.views import password_change
     url = reverse('admin:password_change_done', current_app=self.name)
     defaults = {'current_app': self.name, 'post_change_redirect': url}
     if self.password_change_template is not None:
         defaults['template_name'] = self.password_change_template
     return password_change(request, **defaults)
示例#47
0
def change_password(request):
    """ Allows the user to reset his/her password. """
    extra_context = helpers.get_extra_context(request)
    extra_context['title'] = 'Change Password'
    return views.password_change(
        request,
        template_name='reset/password-change-form.epy',
        extra_context=extra_context,
        post_change_redirect='done',
        password_change_form=forms.PasswordWithMinLengthChangeForm)
示例#48
0
 def password_change(self, request):
     """
     Handles the "change password" task -- both form display and validation.
     """
     from django.contrib.auth.views import password_change
     if self.root_path is not None:
         url = '%spassword_change/done/' % self.root_path
     else:
         url = reverse('admin:password_change_done', current_app=self.name)
     return password_change(request, post_change_redirect=url)
示例#49
0
def password_change_main(request):
    """
    View to update the user password
    """
    extra_context = {
        'form_title': 'Change Password',
        'username': request.user.username,
    }
    return password_change(request, template_name='main/user_form.html',
                           extra_context=extra_context)
示例#50
0
def password_change(request):
    context = {}
    context["page_title"] = _("Password change")

    return django_auth_views.password_change(
        request,
        template_name='account/password-change.html',
        extra_context=context,
        password_change_form=account_forms.CustomPasswordChangeForm,
        post_change_redirect=reverse('account:password-change-done'))
示例#51
0
def password_change(request):
    # Allows a user to change their password.
    return views.password_change(
        request,
        template_name='accounts/password_change_form.html',
        post_change_redirect=reverse('accounts:password_change_done'),
        password_change_form=PasswordChangeForm,
        # current_app=None,
        # extra_context={}
    )
示例#52
0
文件: views.py 项目: hhauer/myinfo
def set_password(request):

    (oam_status, _) = OAMStatusTracker.objects.get_or_create(psu_uuid=request.user.get_username())
    if oam_status.set_password is True:
        form = ChangeOdinPasswordForm
    else:
        form = SetOdinPasswordForm

    return password_change(request=request, template_name='MyInfo/set_password.html',
                           post_change_redirect=reverse('AccountPickup:next_step'), password_change_form=form)
示例#53
0
文件: views.py 项目: oddbird/mlt
def password_change(request):
    response =  auth_views.password_change(
        request,
        template_name="account/password_change_form.html",
        password_change_form=forms.PasswordChangeForm,
        post_change_redirect=DEFAULT_REDIRECT)

    if response.status_code == 302:
        messages.success(request, "Your password has been changed.")

    return response
示例#54
0
def admin_password_change(request):
    """Handle the "change password" task - both display and validation."""
    to_url = reverse('admin:password_change_done', current_app=admin.site.name)
    defaults = {
        'current_app': admin.site.name,
        'post_change_redirect': to_url,
        'password_change_form': StrictPasswordChangeForm
    }
    if admin.site.password_change_template is not None:
        defaults['template_name'] = admin.site.password_change_template
    return password_change(request, **defaults)
示例#55
0
文件: sites.py 项目: bubufox/HomeWork
 def password_change(self, request):
   """
   Handles the "change password" task -- both form display and validation.
   """
   from django.contrib.auth.views import password_change
   url = reverse('site:password_change_done')
   defaults = {
     'post_change_redirect': url,
     'template_name': 'auth/password_change_form.html'
   }
   return password_change(request, **defaults)
示例#56
0
def custom_password_change(request):
    """custom change password form"""
    # check if the request comes from an LDAP account, if so, raise a PermissionDenied exception
    if context_processors.is_ldap_authenticated_user(request)["IS_LDAP_ACCOUNT"]:
        return HttpResponseForbidden("You're not allowed to change your password in this application")

    else:
        return password_change(request,
                               template_name='django_project/change_password.html',
                               extra_context={},
                               post_change_redirect="custom_password_change_done")
示例#57
0
def change_password(request):
    template_name = "shuup/customer_information/change_password.jinja"

    response = password_change(
        request,
        post_change_redirect="shuup:customer_edit",
        template_name=template_name
    )
    if response.status_code == 302:
        messages.success(request, _("Password successfully changed."))
    return response
示例#58
0
    def password_change(self, request):
        """
        Handles the "change password" task -- both form display and validation.
        """
        from django.contrib.auth.views import password_change

        url = reverse("admin:password_change_done", current_app=self.name)
        defaults = {"current_app": self.name, "post_change_redirect": url}
        if self.password_change_template is not None:
            defaults["template_name"] = self.password_change_template
        return password_change(request, **defaults)