53
52
# Check req.app to see if it is valid. 404 if not.
54
53
if req.app is not None and req.app not in conf.apps.app_url:
55
# Maybe it is a special app!
56
if req.app == 'logout':
59
# TODO: Nicer 404 message?
60
req.throw_error(Request.HTTP_NOT_FOUND)
62
# Special handling for public mode - just call public app and get out
63
# NOTE: This will not behave correctly if the public app uses
64
# write_html_head_foot, but "serve" does not.
66
app = conf.apps.app_url[conf.apps.public_app]
67
apps.call_app(app.dir, req)
54
# TODO: Nicer 404 message?
55
req.throw_error(Request.HTTP_NOT_FOUND)
70
57
# app is the App object for the chosen app
71
58
if req.app is None:
72
app = conf.apps.app_url[conf.apps.default_app]
59
app = conf.apps.app_url[conf.default_app]
74
61
app = conf.apps.app_url[req.app]
76
63
# Check if app requires auth. If so, perform authentication and login.
77
# This will either return a User object, None, or perform a redirect
78
# which we will not catch here.
79
64
if app.requireauth:
80
req.user = login.login(req)
81
logged_in = req.user is not None
65
# TODO: Perform authentication
68
# If user did not specify an app, HTTP redirect to default app and exit.
70
req.throw_redirect(util.make_path(conf.default_app))
72
# Set the default title to the app's tab name, if any. Otherwise URL name.
73
if app.name is not None:
83
req.user = login.get_user_details(req)
87
# Keep the user's session alive by writing to the session object.
88
# req.get_session().save()
89
# Well, it's a fine idea, but it creates considerable grief in the
90
# concurrent update department, so instead, we'll just make the
91
# sessions not time out.
93
# If user did not specify an app, HTTP redirect to default app and
96
req.throw_redirect(util.make_path(conf.apps.default_app))
98
# Set the default title to the app's tab name, if any. Otherwise URL
100
if app.name is not None:
105
# Call the specified app with the request object
106
apps.call_app(app.dir, req)
107
# if not logged in, login.login will have written the login box.
108
# Just clean up and exit.
78
# Call the specified app with the request object
79
apps.call_app(app.dir, req)
110
81
# MAKE SURE we write the HTTP (and possibly HTML) header. This
111
82
# wouldn't happen if nothing else ever got written, so we have to make
116
87
if req.write_html_head_foot:
117
88
html.write_html_foot(req)
119
# Note: Apache will not write custom HTML error messages here.
120
# Use req.throw_error to do that.
90
# Have Apache output its own HTML code if non-200 status codes were found
124
"""Log out the current user (if any) by destroying the session state.
125
Then redirect to the top-level IVLE page."""
126
session = req.get_session()
129
req.add_cookie(forumutil.invalidated_forum_cookie())
130
req.throw_redirect(util.make_path(''))