Login
<<Back to Main Menu
Description:
Processes the Login Form to log a user in and create a session which holds the user's username and usertype.
Accessible by:
Users who are not logged in
Accessed from:
Login Form
Input parameters:
Username
Password
Output
If login is successful, either redirects to Main Menu or Booking Form (if the user was forced to log in because they tried to book a flight)
If login is unsuccessful, displays the Login Form with an error message.
Pseudo Code:
get/create session
if (there is no 'username' parameter in the session) { //i.e. user is not logged in
get form parameters
if (form parameters are in the correct format) { //guard against manually generated params
if (the submitted username/password combination exists in the database) {
add the username and user type to the session
if (there is a 'Booking' parameter in the session) { // user is trying to book a flight
display success message and redirect to Booking Form
}
else {
display success message and redirect to Main Menu
}
}
else {
display Login Form with an error message
}
}
else {
display Login Form with an error message
}
}
else {
display an error message
}