File tree 3 files changed +7
-28
lines changed
3 files changed +7
-28
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- #!/users/mtahmed/bin/python
2
-
3
- import sys
4
- sys .path .append ('/users/mtahmed/.local/lib/python3.3/site-packages' )
5
-
6
1
from pyramid .config import Configurator
7
2
from pyramid .response import Response
8
3
from pyramid .view import view_config
9
4
10
- import auth
5
+ from . import auth
11
6
12
7
@view_config (route_name = 'main' , renderer = 'templates/base.jinja2' )
13
8
def main (request ):
14
9
'''View for the main landing page.
15
10
'''
16
11
template_data = dict ()
17
12
18
- a = auth .Auth ()
13
+ a = auth .Auth (user_id = request . remote_user )
19
14
template_data ['user_id' ] = a .get_user_id ()
20
15
21
16
return template_data
@@ -24,12 +19,12 @@ def main(request):
24
19
def logout (request ):
25
20
'''View for the logout page. Only redirects to the logout page.
26
21
'''
27
- a = auth .Auth ()
22
+ a = auth .Auth (user_id = request . remote_user )
28
23
response = Response ()
29
24
30
25
return a .logout (response )
31
26
32
- def make_evote_app ():
27
+ def make_wsgi_app ():
33
28
'''This function returns a Pyramid WSGI application.
34
29
'''
35
30
config = Configurator ()
@@ -45,8 +40,3 @@ def make_evote_app():
45
40
config .include ('pyramid_jinja2' )
46
41
47
42
return config .make_wsgi_app ()
48
-
49
- if __name__ == '__main__' :
50
- import wsgiref .handlers
51
- app = make_evote_app ()
52
- wsgiref .handlers .CGIHandler ().run (make_evote_app ())
Original file line number Diff line number Diff line change 1
- import os
2
-
3
1
class Auth :
4
2
'''This class will provide the voter authentication.
5
3
6
4
Right now it uses the uWaterloo CAS to provide authentication.
7
5
'''
8
6
CAS_LOGOUT_URL = 'https://cas.uwaterloo.ca/cas/logout'
9
7
10
- def __init__ (self ):
11
- self .user_id = os . environ [ 'REMOTE_USER' ]
8
+ def __init__ (self , user_id , is_authed = True ):
9
+ self .user_id = user_id
12
10
# The user is denied if auth fails before they get here so the user must
13
11
# already be authenticated.
14
- self .is_authed = True
12
+ self .is_authed = is_authed
15
13
16
14
def get_user_id (self ):
17
15
return self .user_id
You can’t perform that action at this time.
0 commit comments