Ejemplo n.º 1
0
def auth(request):
    try:
        auth_token = AuthenticationStrategy().authenticate(request)
        request.session['authentication'] = auth_token
    except AuthenticationError:
        request.session['authentication'] = Authentication(None, None)
        return HTTPUnauthorized()
    if (auth_token.is_authenticated()):
        return HTTPFound(location=request.route_url('view_all_elections'))
Ejemplo n.º 2
0
 def test_auth_strategy(self):
     request = self._get_request()
     request.POST['username'] = '******'
     request.POST['password'] = '******'
     auth_token = AuthenticationStrategy().authenticate(request)
     self.assertTrue(auth_token.is_authenticated())