Every line of 'django set password' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
50 def set_password(self, password): 51 self.password = ldap_sha512_crypt.encrypt(password) 52 self.save()
22 def set_password(self, password): 23 return generate_password_hash(password)
226 def set_password(self, password): 227 """Sets an encrypted password. 228 229 :param password: User's password. 230 :type password: str 231 :returns: Password hash. 232 :rtype: str 233 """ 234 return passlib.hash.sha512_crypt.encrypt(password)
33 def set_password(self, password): 34 self.password_hash = bcrypt.generate_password_hash(password)
736 def reset_pwd(request): 737 username = request.POST.get('username') 738 email = request.POST.get('email') 739 user = UserInfo.objects.filter(username=username) 740 if not user: 741 return JsonResponse({"status": "faild", "code": 500, "msg": "用户名不存在"}) 742 743 if email != user.values('email')[0]['email']: 744 return JsonResponse({"status": "faild", "code": 500, "msg": "邮箱地址不正确"}) 745 new_password = get_random_string_from_random(8) 746 UserInfo.objects.set_passwd(username, new_password) 747 subject = "应用管理系统-密码找回--{}".format(settings.__getattr__('EMAIL_ENV')) 748 context = ''' 749 750 751 752 <p>Welcome {}:</p> 753 <span>你的邮箱: {},</span> 754 <span>你的密码:{}</span> 755 756 <br /> 757 <br /> 758 <br /> 759 <p>运维团队 {}</p> 760 761 <p>此邮件为系统自动发送,请勿回复!</p> 762 <p>-----------------------------------------------</p> 763 764 765 766 '''.format(username, email, new_password, get_time_now()) 767 SendEmail(email, subject, context) 768 return JsonResponse({"status": "success", "code": 0})
9 @detail_route(methods=['post'], serializer_class=SetPasswordSerializer) 10 def set_password(self, request, pk): 11 obj = self.get_object() 12 data = request.DATA 13 if isinstance(data, str): 14 data = { 15 'password': data 16 } 17 serializer = SetPasswordSerializer(data=data) 18 if serializer.is_valid(): 19 obj.set_password(serializer.data['password']) 20 try: 21 obj.save(update_fields=['password']) 22 except ValueError: 23 # Some services don't store the password on the database 24 # update_fields=[] doesn't trigger post save! 25 obj.save() 26 return Response({ 27 'status': 'password changed' 28 }) 29 else: 30 return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
44 def change_password(user, password): 45 user.password = encrypt_password(password)
291 def change_password(self, userprofile): 292 password = make_password(self.cleaned_data['password']) 293 userprofile.user.password = password 294 userprofile.user.save() 295 return userprofile
125 def clean_password(self): 126 username = self.cleaned_data.get('username') 127 password = self.cleaned_data.get('password') 128 user = authenticate(username=username, password=password) 129 if not user: 130 raise forms.ValidationError(_("THIS PASSWORD IS INCORRECT"), code='invalid') 131 return password
170 def clean_password2(self): 171 """ 172 Validates that the two password inputs match. 173 174 """ 175 if 'password1' in self.cleaned_data: 176 if self.cleaned_data['password1'] == self.cleaned_data['password2']: 177 self.password = self.cleaned_data['password2'] 178 self.cleaned_data['password'] = self.cleaned_data['password2'] 179 return self.cleaned_data['password2'] 180 else: 181 del self.cleaned_data['password2'] 182 raise forms.ValidationError(self.fields['password2'].error_messages['nomatch']) 183 else: 184 return self.cleaned_data['password2']