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'))
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, '/')
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()