= Login management =
Creating and managing user accounts is a relatively easy exercise. There are many options available, however here is pseudocode to approaching how it might be done
Here is a flow of the process.
= Login management =
== Session management ==
For a user, we want them to log into an account, so we can build up useful services for them. These services could be membership of a club or could accounts in a system. We describe the solution in terms of a public site and its pages.
=== Page 1 Log in ===
On this page we provide a username and password box. We also provide a link to a "Create an account" link.
This page submits the values to page 2.
The page also checks for a query string parameter to see if a log in failed. If it does, then supply help info on screen.
=== Page 2 Log in process ===
This reads the username and password from the form.
We perform a data look up using the "read" function above.
* If a match is found, i.e. the read function returns an Id > 0 then we have a user
* If no match is found, then we have a new account or failed login.
* On a fail, we check again, just for the username. If username found, we can provide extra feedback to Page 1, so to why log in failed.
* On not finding that username, we can go to Page 1 or to Page 3 - new user account.
On a match however.
# We create a random string.
# We data store this random string with this user id (this is a session string).
# We set the secure cookie key in the users browser to the id and a second key to the session string
# We move to Page 5 - Normal operating page.
=== Page 3 New user account ===
On this page we take all the details we want for a user account.
We submit these details to page 4.
We check the querystring for parameters indicating that the new user setup process has failed and provide relevant feedback
=== Page 4 New account process ===
# We read the form values
# We perform a lookup on the primary username to make sure it doesn't already exist
## If a new user, we use the write funtion and bxp will return a new user id
## If an existing user, bounce back to page 3, passing querystring feedback on why the setup failed.
# We create a random string.
# We data store this random string with this user id (this is a session string).
# We set the secure cookie key in the users browser to the id and a second key to the session string
# We move to Page 5
=== Normal operating pages ===
# We retrieve from the session cookie the user id and session string.
# We lookup that id and session string to make sure they match
## If match found, draw the page
## If no match found, redirect back to the login page.
[[Category:Topic:bxp API]]
[[Category:Scenario]]