def post(self, request, *args, **kwargs): '''Reset a user's password and email it to them.''' try: User.reset_password(request.DATA.get('username')) return Response(status=status.HTTP_201_CREATED) except User.DoesNotExist: raise Http404
def post(self, request, *args, **kwargs): '''Reset a user's password and email it to them.''' try: username = request.data.get('username', '') User.reset_password(username=username) return Response({}, status=status.HTTP_201_CREATED) except User.DoesNotExist: raise Http404
def post(self, request, *args, **kwargs): '''Reset a delegate's password and email it to them.''' try: delegate_id = request.data.get('delegate_id', -1) user = User.objects.get(delegate__id=delegate_id) User.reset_password(user=user) return Response({}, status=status.HTTP_201_CREATED) except User.DoesNotExist: raise Http404
def test_reset_delegate_password(self): '''It should correctly reset a delegate's password or raise an error.''' password = '******' delegate = Delegate.objects.create() delegate_user = User.objects.create(username='******', delegate=delegate) delegate_user.set_password(password) delegate_user.save() User.reset_password(user=delegate_user) self.assertFalse(delegate_user.check_password(password))
def test_reset_delegate_password(self): '''It should correctly reset a delegate's password or raise an error.''' password = '******' delegate = Delegate.objects.create() delegate_user = User.objects.create( username='******', delegate=delegate) delegate_user.set_password(password) delegate_user.save() User.reset_password(user=delegate_user) self.assertFalse(delegate_user.check_password(password))
def test_reset_password(self): '''It should correctly reset a user's password or raise an error.''' password = '******' user = models.new_user(username='******', password=password) self.assertTrue(user.check_password(password)) User.reset_password('lololol') user = User.objects.get(id=user.id) self.assertFalse(user.check_password(password)) with self.assertRaises(User.DoesNotExist): models.new_user(username='', email='') User.reset_password('')
def test_reset_password(self): '''It should correctly reset a user's password or raise an error.''' password = '******' user = TestUsers.new_user(username='******', password=password) self.assertTrue(user.check_password(password)) User.reset_password('lololol') user = User.objects.get(id=user.id) self.assertFalse(user.check_password(password)) with self.assertRaises(User.DoesNotExist): TestUsers.new_user(username='', email='') User.reset_password('')