예제 #1
0
파일: user.py 프로젝트: ethanlee16/huxley
 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
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
파일: user.py 프로젝트: bmun/huxley
 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
예제 #5
0
 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
예제 #6
0
파일: user.py 프로젝트: bmun/huxley
 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
예제 #7
0
    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))
예제 #8
0
파일: test_user.py 프로젝트: bmun/huxley
    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))
예제 #9
0
    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('')
예제 #10
0
    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('')