Пример #1
0
 def test_validate_user_has_to_be_active(self):
     """if a user is not active they are redirected to login"""
     u = User()
     u.is_active = False
     u.email = '*****@*****.**'
     u.save()
     # make token
     t = Token()
     t.next = '/'
     t.user = u
     t.save()
     # call view and we're logged in
     r = self.client.get(reverse('zeropass:validate', args=[t.token]))
     # we were redirect to '/'
     self.assertRedirects(r, reverse('zeropass:login'))
Пример #2
0
 def test_validate_valid(self):
     """when validate is passed a valid token a user is logged in"""
     # make user
     u = User()
     u.is_active = True
     u.email = '*****@*****.**'
     u.save()
     # make token
     t = Token()
     t.next = '/'
     t.user = u
     t.save()
     # call view and we're logged in
     r = self.client.get(reverse('zeropass:validate', args=[t.token]))
     # we were redirect to '/'
     self.assertRedirects(r, '/')
Пример #3
0
 def save(self):
     token = Token()
     token.user = self.user
     token.next = self.cleaned_data.get("next")
     token.expires = datetime.now() + timedelta(seconds=conf.EXPIRES)
     token.save()