def post(self, request, *args, **kwargs): user = request.user data = request.data old_pwd = data.get('old_pwd') new_pwd = data.get('new_pwd') (is_valid, msg) = check_pwd(new_pwd) if not is_valid: tpl = 'customer/safety/password/update_login_pwd_failed.html' return render(request, tpl, {'msg': msg}) m = {} if user.check_password(old_pwd): # 进入修改成功页面 tpl = 'customer/safety/password/update_login_pwd_suc.html' user.set_password(new_pwd) user.save(update_fields=['password']) else: # # 进入修改失败页面 # tpl = 'customer/safety/password/update_login_pwd_failed.html' tpl = 'customer/safety/password/update_login_pwd.html' m['old_pwd_err_msg'] = u'原密码错误' return render(request, tpl, m)
def check_password_setting(self): if not len(self.password_extraction()): logs.ISSUE("No password has been set. ") logs.RECOMMENDATION("requirepass [your_password]") return 0 password = self.password_extraction()[0] if utils.check_pwd(password): logs.DEBUG('Password is strong') else: logs.ISSUE('Password could be easily guessed.') logs.RECOMMENDATION("requirepass [stronger passwor]")
def check_authentication(self): if utils.get_item_from_obj(self.content, "spark.authenticate", default="false") == "false": logs.ISSUE("Everyone can visit the instance") logs.RECOMMENDATION("spark.authenticate = true") else: logs.DEBUG("Authentication is enabled") password = utils.get_item_from_obj(self.content, "spark.authenticate.secret", default="") if utils.check_pwd(password): logs.DEBUG('Password is strong') else: logs.ISSUE('Password could be easily guessed.') logs.RECOMMENDATION( "spark.authenticate.secret [stronger passwor]")
def post(self, request, *args, **kwargs): user = request.user data = request.data is_upd = 'old_pwd' in data old_pwd = data.get('old_pwd') new_pwd = data.get('new_pwd') (is_valid, msg) = check_pwd(new_pwd) if not is_valid: if old_pwd: tpl = 'customer/safety/paypwd/update_pay_pwd_failed.html' else: tpl = 'customer/safety/paypwd/set_pay_pwd_failed.html' return render(request, tpl, {'msg': msg}) m = {} user_profile = UserProfile.objects.filter(user=user).last() failed = False tpl = '' if user_profile and user_profile.pay_pwd and not check_password(old_pwd, user_profile.pay_pwd): failed = True m['old_pwd_err_msg'] = u'原密码错误' elif user.check_password(new_pwd): failed = True m['new_pwd_err_msg'] = u'资金密码不能和登录密码相同' elif not user_profile: UserProfile(user=user, pay_pwd=make_password(new_pwd)).save() # 进入修改成功页面 tpl = 'customer/safety/paypwd/set_pay_pwd_suc.html' elif not user_profile.pay_pwd: user_profile.pay_pwd = make_password(new_pwd) user_profile.save(update_fields=['pay_pwd', 'modified_date', 'modified_time']) tpl = 'customer/safety/paypwd/update_pay_pwd_suc.html' else: user_profile.pay_pwd = make_password(new_pwd) user_profile.save(update_fields=['pay_pwd', 'modified_date', 'modified_time']) tpl = 'customer/safety/paypwd/update_pay_pwd_suc.html' if failed: if is_upd: tpl = 'customer/safety/paypwd/update_pay_pwd.html' else: tpl = 'customer/safety/paypwd/set_pay_pwd.html' return render(request, tpl, m)