def post(self, request): username = request.data["username"] try: user = User.objects.get(username=username) except User.DoesNotExist: return Response({"status": "user_not_found"}) new_password = utils.generate_password() user.set_password(new_password) user.save() send_password(user, new_password) return Response({"status": "ok"})
def post(self, request): username = request.data["username"] first_name = request.data["name"] new_password = utils.generate_password() try: user = User.objects.get(username=username) user.set_password(new_password) user.first_name = first_name user.save() except User.DoesNotExist: user = User.objects.create_user(username, username, new_password) user.first_name = first_name user.save() send_password(user, new_password) return Response({"status": "ok"})
def __generate_secret_key(self): """ Generate the secret key (private part) """ self.secret_key_clear = utils.generate_password(40)
def test_generate_password(self): password = utils.generate_password(32) self.assertEqual(32, len(password))
def __generate_salt(self): """ Generate the salt """ self.salt = utils.generate_password(20)