Usage Example

Before explaining what is needed to set up the authentication sample, let's describe the scenario:

  1. There is an admin page which is used to manage user data (example.com/auth/).
  2. Opening this page without being logged in as a member of the admin group redirects you to a login page (example.com/auth/login/).
  3. A form is displayed on this page requiring you to fill in your credentials.
  4. Now if you submit something invalid, the form is redisplayed containing an error message describing the problem.
  5. If the verification of the data you supply is successful you will be redirected either to a member's page or to the admin page mentioned earlier, depending on which group you belong to.
  6. Then, let's say you forgot your password.
  7. Open the "Forgot Password" page, enter your email address and hit the send button (example.com/auth/forgotPassword/).
  8. Now, while you are redirected to the login page there is an email waiting for you containing a link to a "Reset Password" page (example.com/auth/resetPassword/).
  9. On this page enter a new password, confirm it and hit the submit button.
  10. You are redirected to the login page where you can enter your new password.
  11. To change your password open the "Change Password" page (example.com/auth/changePassword/), enter your email address and your password. Hit the submit button.
  12. The procedure which follows is similar to the forgotten password one.
  13. Now, let's say you logged in as a member of the admin group.
  14. You will be presented with the administration page (example.com/auth/).
  15. There you can create new users, activate / deactivate, edit and delete users.

 

Note: The structure of the required authentication database is outlined in section Authentication Tables.

 

The sample environment consists of the following files:

  1. A controller to receive and process the submitted data.
  2. A form validation file.
  3. Various view files containing forms or a users table.
  4. A CSS file.

Let's create those files.

The Controller

We start with the basic authentication controller script containing just the handler to load helpers respectively libraries and the default (index) handler. Create a controller called auth.lc. In it, place the code below and save it to your application/controllers/ folder.

<?lc

put "auth,index,login,logout,createUser,activate,deactivate,forgotPassword" & \
",resetPassword,changePassword,editUser,deleteUser" into gControllerHandlers


command auth
 # LOAD HELPERS
 put "form,url,asset" into tHelpers
 rigLoadHelper tHelpers

 # LOAD LIBRARIES
 rigLoaderLoadLibrary "Formvalidation"
 rigLoaderLoadLibrary "Table"
 rigLoaderLoadLibrary "Authentication"
end auth



command index
 # SET PAGE TITLE
 put "Auth Test Admin Page" into gData["pageTitle"]

 # CHECK IF USER IS LOGGED IN
 if rigAuthLoggedIn() is FALSE then
  # REDIRECT TO LOGIN PAGE AND KEEP FLASHDATA IN CASE THERE IS ANY
  if rigSessFlashdata("message") <> FALSE then
   rigKeepSessFlashdata "message"
  end if

  rigRedirect "auth/login"

 else if rigAuthIsAdmin() is FALSE then
  # REDIRECT TO HOME PAGE BECAUSE USER IS NOT ALLOWED TO VIEW ADMIN CONTENT
  rigRedirect "/"

 else
  # ADMIN CONTENT
  #
  # SHOW VALIDATION ERRORS OR FLASH DATA IN CASE THERE IS ANY
  put rigValidationErrors("<div class=" & quote & "error" & quote & ">", "</div>") into tErrors
  if tErrors <> empty then
   put tErrors into gData["message"]
  else
   put rigSessFlashdata("message") into gData["message"]
   if gData["message"] is FALSE then
    put empty into gData["message"]
   end if
  end if

  # BUILD USERS LIST
  put rigAuthUsers() into tResult -- gData["users"]

  if tResult <> FALSE then

   # BUILD MODIFIED RESULT ARRAY
   put 0 into tIncr
   repeat for each key tKey in tResult
    add 1 to tIncr

    put tResult[tIncr] into tRow
    # GET FIRST, LAST NAME AND EMAIL
    put tRow[13] into tResultData[tIncr][1]
    put tRow[14] into tResultData[tIncr][2]
    put tRow[5] into tResultData[tIncr][3]

    # GET USERS GROUPS
    put rigAuthUserGroups(tRow[1]) into tGroupsResult

    if tGroupsResult <> FALSE then
     repeat for each key tKey in tGroupsResult
      put tGroupsResult[tKey] into tGroupsRow
      # GET NAME OF GROUP
      put tGroupsRow[2] & ", " after tResultData[tIncr][4]
     end repeat
     delete char -2 to -1 of tResultData[tIncr][4]
    end if

    # GET STATUS
    if tRow[12] is 1 then
     put rigAnchor("auth/deactivate/" & tRow[1], "Active") into tResultData[tIncr][5]
    else
     put rigAnchor("auth/activate/" & tRow[1], "Inactive") into tResultData[tIncr][5]
    end if

    # LINK TO EDIT USER
    put rigAnchor("auth/editUser/" & tRow[1], "Edit") into tResultData[tIncr][6]

    # LINK TO DELETE USER
    put rigAnchor("auth/deleteUser/" & tRow[1], "Delete") into tResultData[tIncr][7]
   end repeat

   # NOW GENERATE A USERS TABLE
   put "First Name", "Last Name", "Email", "Groups", "Status", "Edit, Delete" into tFieldnames
   rigSetTableHeading tFieldnames
   put rigGenerateTable(tResultData) into gData["usersTable"]
  end if

  # LINK TO LOGOUT
  put rigAnchor("auth/logout/", "Logout") into gData["logoutLink"]

  # LINK TO CREATE NEW USER
  put rigAnchor("auth/createUser/", "Create New User.") into gData["newUserLink"]

  # LOAD THE VIEW FILE
  get rigLoadView("auth/authMainView")
 end if
end index
Top of Page

Add the following code which is needed to create new user data.

command createUser
 put "Auth Test Create User" into gData["pageTitle"]

 # CHECK IF USER IS NOT LOGGED IN OR IF USER IS NOT ADMIN
 if (rigAuthLoggedIn() is not TRUE) or (rigAuthIsAdmin() is not TRUE) then
  # REDIRECT TO ADMIN (LOGIN) PAGE
  rigRedirect "auth/"
 end if

 # FORM OPEN
 put "authForm" into tFormAttr["id"]
 put rigFormOpen("auth/createUser", tFormAttr) into gData["formOpen"]

 # FIELD SET
 put rigFormFieldset("User Data") into gData["fsOpen"]
 put rigFormFieldsetClose() into gData["fsClose"]

 # FORM LABELS
 put "formLabel" into tLabelAttr["class"]
 put rigFormLabel("First Name:", "first", tLabelAttr) into gData["firstLabel"]
 put rigFormLabel("Last Name:", "last", tLabelAttr) into gData["lastLabel"]
 put rigFormLabel("Company:", "company", tLabelAttr) into gData["companyLabel"]
 put rigFormLabel("Email:", "email", tLabelAttr) into gData["emailLabel"]
 put rigFormLabel("Phone:", "phone", tLabelAttr) into gData["phoneLabel"]
 put rigFormLabel("Password:", "password", tLabelAttr) into gData["passwordLabel"]
 put rigFormLabel("Confirm Password:", "passwordConfirm", tLabelAttr) into gData["passwordConfirmLabel"]

 # SUBMIT
 put "createSubmit" into tSubmitArr["name"]
 put "Create User" into tSubmitArr["value"]
 put "createBtn" into tSubmitArr["id"]
 put rigSubmitButton(tSubmitArr) into gData["createSubmit"]

 # FORM VALIDATION
 if rigFormValidRun("auth/createUser") is TRUE then
  # GET ACCOUNT DATA
  if $_POST is an array then
   put toLower(rigVarPOST("first")) && toLower(rigVarPOST("last")) into tUserName
   put rigVarPOST("password") into tPassword
   put rigVarPOST("email") into tEmail

   put rigVarPOST("first") into tExtraData["firstName"]
   put rigVarPOST("last") into tExtraData["lastName"]
   put rigVarPOST("company") into tExtraData["company"]
   put rigVarPOST("phone") into tExtraData["phone"]
  end if

  put rigAuthRegister(tUserName, tPassword, tEmail, tExtraData) into tRegistration

  # CHECK REGISTRATION DATA
  if tRegistration is an array then
   rigLogMessage "debug", "identity:" && tRegistration["identity"]
   rigLogMessage "debug", "id:" && tRegistration["id"]
   rigLogMessage "debug", "email:" && tRegistration["email"]
   rigLogMessage "debug", "activationCode:" && tRegistration["activationCode"]
  else
   rigLogMessage "debug", "tRegistration:" && tRegistration
  end if
  rigLogMessage "debug", "messages:" && rigAuthMessages()
  #

  # IF REGISTRATION WAS SUCCESSFUL REDIRECT TO AUTHENTICATION PAGE
  if tRegistration <> FALSE then    
   put rigAuthMessages() into tMessages
   rigSetSessFlashdata "message", tMessages
   rigRedirect "/auth"
  else
   # LOAD VIEW
   put rigAuthErrors() into tErrors
   rigSetSessFlashdata "message", tErrors
   rigRedirect "auth/createUser"
  end if

 else -- if rigFormValidRun("auth/createUser") is TRUE then

  put rigValidationErrors("<div class=" & quote & "error" & quote & ">", "</div>") into tErrors
  if tErrors <> empty then
   put tErrors into gData["message"]
  else
   put rigSessFlashdata("message") into gData["message"]
   if gData["message"] is FALSE then
    put empty into gData["message"]
   end if
  end if

  # INPUT FIELDS
  put "first" into tInFirstArr["name"]
  # RE-POPULATE THE FIELD
  put rigSetValue("first") into tInFirstArr["value"]
  put "50" into tInFirstArr["maxlength"]
  put rigFormInput(tInFirstArr) into gData["first"]

  put "last" into tInLastArr["name"]
  # RE-POPULATE THE FIELD
  put rigSetValue("last") into tInLastArr["value"]
  put "50" into tInLastArr["maxlength"]
  put rigFormInput(tInLastArr) into gData["last"]

  put "company" into tInCompArr["name"]
  # RE-POPULATE THE FIELD
  put rigSetValue("company") into tInCompArr["value"]
  put "100" into tInCompArr["maxlength"]
  put rigFormInput(tInCompArr) into gData["company"]

  put "email" into tInMailArr["name"]
  # RE-POPULATE THE FIELD
  put rigSetValue("email") into tInMailArr["value"]
  put "50" into tInMailArr["maxlength"]
  put rigFormInput(tInMailArr) into gData["email"]

  put "phone" into tInPhoneArr["name"]
  # RE-POPULATE THE FIELD
  put rigSetValue("phone") into tInPhoneArr["value"]
  put "50" into tInPhoneArr["maxlength"]
  put rigFormInput(tInPhoneArr) into gData["phone"]

  put "password" into tInPassArr["name"]
  # RE-POPULATE THE FIELD
  put rigSetValue("password") into tInPassArr["value"]
  put "50" into tInPassArr["maxlength"]
  put rigFormInput(tInPassArr) into gData["password"]

  put "passwordConfirm" into tInPassConfArr["name"]
  # RE-POPULATE THE FIELD
  put rigSetValue("passwordConfirm") into tInPassConfArr["value"]
  put "50" into tInPassConfArr["maxlength"]
  put rigFormInput(tInPassConfArr) into gData["passwordConfirm"]
 end if

 # LOAD VIEW
 get rigLoadView("auth/createUserMainView")
end createUser
Top of Page

Add the login handler.

command login
 put "Auth Test Login" into gData["pageTitle"]

 # FORM OPEN
 put "authForm" into tFormAttr["id"]
 put rigFormOpen("auth/login", tFormAttr) into gData["formOpen"]

 # FIELD SET
 put rigFormFieldset("Login Form") into gData["fsOpen"]
 put rigFormFieldsetClose() into gData["fsClose"]

 # FORM LABELS
 put "formLabel" into tLabelAttr["class"]
 put rigFormLabel("Email/Username:", "identity", tLabelAttr) into gData["identityLabel"]
 put rigFormLabel("Password:", "password", tLabelAttr) into gData["passwordLabel"]
 put rigFormLabel("Remember me:", "remember", tLabelAttr) into gData["rememberLabel"]

 # SUBMIT
 put "loginSubmit" into tSubmitArr["name"]
 put "Login" into tSubmitArr["value"]
 put "loginBtn" into tSubmitArr["id"]
 put rigSubmitButton(tSubmitArr) into gData["loginSubmit"]

 # FORM VALIDATION
 if rigFormValidRun("auth/login") is TRUE then

  # CHECK IF USER IS LOGGING IN    
  # REMEMBER ME CHECK BOX
  put FALSE into tRemember
  # CHECK IF THERE IS A POST VARIABLE remember
  put rigVarPost("remember[]") into tPostRemember
  if tPostRemember <> FALSE then
   # CHECK VALUE
   if tPostRemember[1] is 1 then
    put TRUE into tRemember
   end if
  end if

  get rigAuthLogin(rigVarPost("identity"), rigVarPost("password"), tRemember)

  # IF LOGIN IS SUCCESSFUL REDIRECT BACK TO HOME PAGE, auth IN THIS CASE
  if it is TRUE then
   put rigAuthMessages() into tMessages
   rigSetSessFlashdata "message", tMessages
   rigRedirect "/auth"

  else
   # IF LOGIN IS UNSUCCESSFUL REDIRECT BACK TO THE LOGIN PAGE
   put rigAuthErrors() into tErrors
   rigSetSessFlashdata "message", tErrors
   rigRedirect "auth/login"
  end if


 else
  # THE USER IS NOT LOGGING IN, SHOW THE LOGIN PAGE
  # SHOW VALIDATION ERRORS OR FLASH DATA IF THERE IS ANY
  put rigValidationErrors("<div class=" & quote & "error" & quote & ">", "</div>") into tErrors
  if tErrors <> empty then
   put tErrors into gData["message"]
  else
   put rigSessFlashdata("message") into gData["message"]
   if gData["message"] is FALSE then
    put empty into gData["message"]
   end if
  end if

  # INPUT FIELDS
  put "identity" into tInIdentArr["name"]
  # RE-POPULATE THE FIELD
  put rigSetValue("identity") into tInIdentArr["value"]
  put "100" into tInIdentArr["maxlength"]
  put rigFormInput(tInIdentArr) into gData["identity"]

  put "password" into tInPwArr["name"]
  put "40" into tInPwArr["maxlength"]
  put rigFormInput(tInPwArr) into gData["loginPassword"]

  # CHECKBOX
  put rigSetCheckbox("remember[]", "1", TRUE) into gData["chbRemember"]

  get rigLoadView("auth/loginMainView")

 end if -- if rigFormValidRun("auth/login") is TRUE then
end login
Top of Page

Of course there is a logout handler.

command logout
 # LOG USER OUT
 rigAuthLogout

 # REDIRECT TO THE LOGIN PAGE
 put rigAuthMessages() into tMessages

 rigSetSessFlashdata "message", tMessages
 rigRedirect "/auth/login"
end logout
Top of Page

Add the following user activation handler.

command activate
 # GET USER ID AND ACTIVATION CODE
 put rigFetchSegment(3) into tID
 put rigFetchSegment(4) into tCode
 put FALSE into tActivation

 # ACTIVATE USER
 if tCode <> FALSE then
  put rigAuthActivate(tID, tCode) into tActivation

 else if rigAuthIsAdmin() is TRUE then
  put rigAuthActivate(tID) into tActivation
 end if

 # CHECK IF ACTIVATION WAS SUCCESSFUL AND ACT ACCORDINGLY
 if tActivation is TRUE then
  # REDIRECT TO THE AUTH PAGE
  put rigAuthMessages() into tMessages

  rigSetSessFlashdata "message", tMessages
  rigRedirect "/auth"

 else
  put rigAuthErrors() into tErrors

  rigSetSessFlashdata "message", tErrors
  rigRedirect "auth/forgotPassword"
 end if  
end activate
Top of Page

Add the user deactivation handler.

command deactivate
 put "Auth Test Deactivate" into gData["pageTitle"]

 put rigFetchSegment(3) into tID

 # FORM OPEN
 put "authForm" into tFormAttr["id"]
 put rigFormOpen("auth/deactivate/" & tID, tFormAttr) into gData["formOpen"]

 # FIELD SET
 put rigFormFieldset("Deactivate User Form") into gData["fsOpen"]
 put rigFormFieldsetClose() into gData["fsClose"]

 # FORM LABELS
 put "formLabel" into tLabelAttr["class"]
 put rigFormLabel("Yes:", "confirm", tLabelAttr) into gData["confirmRadioYesLabel"]
 put rigFormLabel("No:", "confirm", tLabelAttr) into gData["confirmRadioNoLabel"]

 # SUBMIT
 put "deactivateSubmit" into tSubmitArr["name"]
 put "Submit" into tSubmitArr["value"]
 put "submitBtn" into tSubmitArr["id"]
 put rigSubmitButton(tSubmitArr) into gData["deactivateSubmit"]

 # FORM VALIDATION
 if rigFormValidRun("auth/deactivate") is TRUE then
  put FALSE into tDeactivated

  # CHECK IF DEACTIVATION WAS CONFIRMED
  if rigVarPOST("confirm") is "yes" then

   # VALIDATE THE REQUEST
   if tID <> rigVarPOST("id") then
    rigLogMessage "error", "This user deactivation form post did not pass the security check.", TRUE
   end if

   # CHECK THE USER LEVEL
   if (rigAuthLoggedIn() is TRUE) and (rigAuthIsAdmin() is TRUE) then
    put rigAuthDeactivate(tID) into tDeactivated
   end if

  end if

  # GET AUTH MESSAGES AND REDIRECT TO THE AUTH PAGE
  if tDeactivated is TRUE then
   put rigAuthMessages() into tMessages
  else
   put rigAuthErrors() into tMessages
  end if

  rigSetSessFlashdata "message", tMessages
  rigRedirect "/auth"

 else
  put rigValidationErrors("<div class=" & quote & "error" & quote & ">", "</div>") into tErrors
  if tErrors <> empty then
   put tErrors into gData["message"]
  else
   put rigSessFlashdata("message") into gData["message"]
   if gData["message"] is FALSE then
    put empty into gData["message"]
   end if
  end if

  # HIDDEN USER ID FIELD
  put rigAuthUser(tID) into tQueryResult
  if (tQueryResult <> FALSE) and (tQueryResult is an array) then
   put rigDbRow() into tUserRow
   put tUserRow["id"] into tUserID
   put tUserRow["username"] into gData["userName"]
  else
   put empty into tUserID
  end if
  put rigFormHidden("id", tUserID) into gData["hiddenUserID"]

  # RADIO BUTTONS
  put rigSetRadio("confirm", "yes") into gData["confirmYes"]
  put rigSetRadio("confirm", "no", TRUE) into gData["confirmNo"]

  # LOAD VIEWS
  get rigLoadView("auth/deactivateUserMainView")
 end if
end deactivate
Top of Page

Add the "forgotPassword" handler.

command forgotPassword
 put "Auth Test Forgot Password" into gData["pageTitle"]

 put rigSessFlashdata("message") into gData["message"]

 # FORM OPEN
 put "authForm" into tFormAttr["id"]
 put rigFormOpen("auth/forgotPassword/", tFormAttr) into gData["formOpen"]

 # FIELD SET
 put rigFormFieldset("Forgot Password Form") into gData["fsOpen"]
 put rigFormFieldsetClose() into gData["fsClose"]

 # FORM LABELS
 put "formLabel" into tLabelAttr["class"]
 put rigFormLabel("Email:", "email", tLabelAttr) into gData["emailLabel"]

 # SUBMIT
 put "forgotSubmit" into tSubmitArr["name"]
 put "Submit" into tSubmitArr["value"]
 put "forgotBtn" into tSubmitArr["id"]
 put rigSubmitButton(tSubmitArr) into gData["forgotSubmit"]

 # FORM VALIDATION
 if rigFormValidRun("auth/forgotPassword") is TRUE then
  # CALL THE rigAuthForgottenPassword FUNCTION TO SEND A RESET CODE TO THE USER
  put rigAuthForgottenPassword(rigVarPOST("email")) into tResetPasswordSent

  if tResetPasswordSent is TRUE then
   put rigAuthMessages() into tMessages

   rigSetSessFlashdata "message", tMessages
   rigRedirect "/auth/login"
  else
   put rigAuthErrors() into tErrors

   rigSetSessFlashdata "message", tErrors
   rigRedirect "auth/forgotPassword"
  end if    

 else
  put rigValidationErrors("<div class=" & quote & "error" & quote & ">", "</div>") into tErrors
  if tErrors <> empty then
   put tErrors into gData["message"]
  else
   put rigSessFlashdata("message") into gData["message"]
   if gData["message"] is FALSE then
    put empty into gData["message"]
   end if
  end if

  # INPUT FIELDS
  put "email" into tInMailArr["name"]
  # RE-POPULATE THE FIELD
  put rigSetValue("email") into tInMailArr["value"]
  put "50" into tInMailArr["maxlength"]
  put rigFormInput(tInMailArr) into gData["email"]
 end if

 # LOAD VIEW
 get rigLoadView("auth/forgotPasswordMainView")
end forgotPassword
Top of Page

Add code which is used to reset passwords in case a user forgot the password or sent a change password request.

command resetPassword
 put "Auth Test Reset Password" into gData["pageTitle"]

 put rigFetchSegment(3) into tForgottenPasswordCode

 if tForgottenPasswordCode is FALSE then
  rigShow404
 end if

 put rigAuthForgottenPasswordCheck(tForgottenPasswordCode) into tUser

 if tUser <> FALSE then
  put rigAuthFetchConfigItem("minLengthPassword") into tMinPasswordLength
  put rigAuthFetchConfigItem("maxLengthPassword") into tMaxPasswordLength

  # FORM OPEN
  put "authForm" into tFormAttr["id"]
  put rigFormOpen("auth/resetPassword/" & tForgottenPasswordCode, tFormAttr) into gData["formOpen"]

  # FIELD SET
  put rigFormFieldset("Reset Password Form") into gData["fsOpen"]
  put rigFormFieldsetClose() into gData["fsClose"]

  # FORM LABELS
  put "formLabel" into tLabelAttr["class"]
  put rigFormLabel("New Password (at least" && tMinPasswordLength && "characters long):", \
"newPassword", tLabelAttr) into gData["newPasswordLabel"]
  put rigFormLabel("Confirm New Password:", "newPasswordConfirm", tLabelAttr) into gData["newPasswordConfirmLabel"]

  # SUBMIT
  put "resetSubmit" into tSubmitArr["name"]
  put "Change" into tSubmitArr["value"]
  put "resetBtn" into tSubmitArr["id"]
  put rigSubmitButton(tSubmitArr) into gData["resetSubmit"]

  # IF THE CODE IS VALID DISPLAY THE PASSWORD RESET FORM
  # FORM VALIDATION
  if rigFormValidRun("auth/resetPassword") is TRUE then

   # VALIDATE THE REQUEST
   if tUser["id"] <> rigVarPOST("hiddenUserID") then
    get rigAuthClearForgottenPasswordCode(tForgottenPasswordCode)
    rigLogMessage "error", "This reset password form post did not pass the security check.", TRUE

   else
    # CHANGE THE PASSWORD
    put rigAuthFetchConfigItem("identityColumn") into tIdentityCol
    put tUser[tIdentityCol] into tIdentity

    put rigAuthResetPassword(tIdentity, rigVarPOST("newPassword")) into tChange

    if tChange is TRUE then
     # THE PASSWORD WAS SUCCESSFULLY CHANGED
     put rigAuthMessages() into tMessages

     rigSetSessFlashdata "message", tMessages
     logout

    else
     put rigAuthErrors() into tErrors

     rigSetSessFlashdata "message", tErrors
     rigRedirect "auth/resetPassword/" & tForgottenPasswordCode
    end if

   end if

  else
   # DISPLAY THE FORM
   # SET THE FLASH DATA ERROR MESSAGE IF THERE IS ONE
   put rigValidationErrors("<div class=" & quote & "error" & quote & ">", "</div>") into tErrors
   if tErrors <> empty then
    put tErrors into gData["message"]
   else
    put rigSessFlashdata("message") into gData["message"]
    if gData["message"] is FALSE then
     put empty into gData["message"]
    end if
   end if

   # INPUT FIELDS
   put "newPassword" into tInPassArr["name"]
   put tMaxPasswordLength into tInPassArr["maxlength"]
   put "password" into tInPassArr["type"]
   put rigFormInput(tInPassArr) into gData["newPassword"]

   put "newPasswordConfirm" into tInPassConfArr["name"]
   put tMaxPasswordLength into tInPassConfArr["maxlength"]
   put "password" into tInPassConfArr["type"]
   put rigFormInput(tInPassConfArr) into gData["newPasswordConfirm"]

   put "hiddenUserID" into tInUserIdArr["name"]
   put tUser["id"] into tInUserIdArr["value"]
   put "hidden" into tInUserIdArr["type"]
   put rigFormInput(tInUserIdArr) into gData["hiddenUserID"]

   # LOAD VIEW
   get rigLoadView("auth/resetPasswordMainView")

  end if -- if rigFormValidRun("auth/forgotPassword") is TRUE then

 else  -- if tUser <> FALSE then
  put rigAuthErrors() into tErrors

  rigSetSessFlashdata "message", tErrors
  rigRedirect "auth/forgotPassword"
 end if -- if tUser <> FALSE then

end resetPassword
Top of Page

Add a handler which is used to change passwords.

command changePassword
 put "Auth Test Change Password" into gData["pageTitle"]

 # CHECK IF USER IS LOGGED IN
 if rigAuthLoggedIn() is FALSE then
  rigRedirect "/auth/login"
 end if

 # GET USER DATA
 put rigAuthUser() into tQueryResult

 if (tQueryResult <> FALSE) and (tQueryResult is an array) then
  put rigDbRow() into tUser
 end if

 # GET MIN / MAX PASSWORD LENGTH
 put rigAuthFetchConfigItem("minLengthPassword") into tMinPasswordLength
 put rigAuthFetchConfigItem("maxLengthPassword") into tMaxPasswordLength

 # FORM OPEN
 put "authForm" into tFormAttr["id"]
 put rigFormOpen("auth/changePassword/", tFormAttr) into gData["formOpen"]

 # FIELD SET
 put rigFormFieldset("Change Password Form") into gData["fsOpen"]
 put rigFormFieldsetClose() into gData["fsClose"]

 # FORM LABELS
 put "formLabel" into tLabelAttr["class"]
 put rigFormLabel("Old Password:", "oldPassword", tLabelAttr) into gData["oldPasswordLabel"]
 put rigFormLabel("New Password (at least" && tMinPasswordLength && "characters long):", \
"newPassword", tLabelAttr) into gData["newPasswordLabel"]
 put rigFormLabel("Confirm New Password:", "newPasswordConfirm", tLabelAttr) into gData["newPasswordConfirmLabel"]

 # SUBMIT
 put "changeSubmit" into tSubmitArr["name"]
 put "Change" into tSubmitArr["value"]
 put "changeBtn" into tSubmitArr["id"]
 put rigSubmitButton(tSubmitArr) into gData["changeSubmit"]

 # FORM VALIDATION
 if rigFormValidRun("auth/changePassword") is TRUE then
  put rigAuthFetchConfigItem("identityColumn") into tIdentityCol
  put rigSessUserdata(tIdentityCol) into tIdentity

  put rigAuthChangePassword(tIdentity, rigVarPOST("oldPassword"), rigVarPOST("newPassword")) into tChange

  if tChange is TRUE then
   # THE PASSWORD WAS SUCCESSFULLY CHANGED
   put rigAuthMessages() into tMessages

   rigSetSessFlashdata "message", tMessages
   logout

  else
   put rigAuthErrors() into tErrors

   rigSetSessFlashdata "message", tErrors
   rigRedirect "auth/changePassword/" & tForgottenPasswordCode
  end if

 else
  # DISPLAY THE FORM
  # SET THE FLASH DATA ERROR MESSAGE IF THERE IS ONE
  put rigValidationErrors("<div class=" & quote & "error" & quote & ">", "</div>") into tErrors
  if tErrors <> empty then
   put tErrors into gData["message"]
  else
   put rigSessFlashdata("message") into gData["message"]
   if gData["message"] is FALSE then
    put empty into gData["message"]
   end if
  end if

  # INPUT FIELDS
  put "oldPassword" into tInOldPassArr["name"]
  put tMaxPasswordLength into tInOldPassArr["maxlength"]
  put "password" into tInOldPassArr["type"]
  put rigFormInput(tInOldPassArr) into gData["oldPassword"]

  put "newPassword" into tInPassArr["name"]
  put tMaxPasswordLength into tInPassArr["maxlength"]
  put "password" into tInPassArr["type"]
  put rigFormInput(tInPassArr) into gData["newPassword"]

  put "newPasswordConfirm" into tInPassConfArr["name"]
  put tMaxPasswordLength into tInPassConfArr["maxlength"]
  put "password" into tInPassConfArr["type"]
  put rigFormInput(tInPassConfArr) into gData["newPasswordConfirm"]

  put "hiddenUserID" into tInUserIdArr["name"]
  put tUser["id"] into tInUserIdArr["value"]
  put "hidden" into tInUserIdArr["type"]
  put rigFormInput(tInUserIdArr) into gData["hiddenUserID"]

  # LOAD VIEW
  get rigLoadView("auth/changePasswordMainView")

 end if -- if rigFormValidRun("auth/resetPassword") is TRUE then
end changePassword
Top of Page

Add a handler which is used to edit user data.

command editUser
 put "Auth Test Edit User" into gData["pageTitle"]

 # CHECK IF USER IS NOT LOGGED IN OR IF USER IS NOT ADMIN
 if (rigAuthLoggedIn() is not TRUE) or (rigAuthIsAdmin() is not TRUE) then
  # REDIRECT TO AUTH PAGE
  rigRedirect "auth/"
 end if

 # GET MIN / MAX PASSWORD LENGTH
 put rigAuthFetchConfigItem("minLengthPassword") into tMinPasswordLength
 put rigAuthFetchConfigItem("maxLengthPassword") into tMaxPasswordLength

 # GET USER ID
 put rigFetchSegment(3) into tID

 # GET STORED USER DATA
 put rigAuthUser(tID) into tQueryResult
 if (tQueryResult <> FALSE) and (tQueryResult is an array) then
  put rigDbRow() into tUser
 end if

 # FORM OPEN
 put "authForm" into tFormAttr["id"]
 put rigFormOpen("auth/editUser/" & tID, tFormAttr) into gData["formOpen"]

 # FIELD SET
 put rigFormFieldset("Edit User") into gData["fsOpen"]
 put rigFormFieldsetClose() into gData["fsClose"]

 # FORM LABELS
 put "formLabel" into tLabelAttr["class"]
 put rigFormLabel("First Name:", "first", tLabelAttr) into gData["firstLabel"]
 put rigFormLabel("Last Name:", "last", tLabelAttr) into gData["lastLabel"]
 put rigFormLabel("Company:", "company", tLabelAttr) into gData["companyLabel"]
 put rigFormLabel("Phone:", "phone", tLabelAttr) into gData["phoneLabel"]
 put rigFormLabel("Password:", "password", tLabelAttr) into gData["passwordLabel"]
 put rigFormLabel("Confirm Password:", "passwordConfirm", tLabelAttr) into gData["passwordConfirmLabel"]

 # SUBMIT
 put "editSubmit" into tSubmitArr["name"]
 put "Save User" into tSubmitArr["value"]
 put "editBtn" into tSubmitArr["id"]
 put rigSubmitButton(tSubmitArr) into gData["editSubmit"]

 # CHECK POST ARRAY DATA
 if $_POST is an array then
  # VALIDATE THE REQUEST
  if tID <> rigVarPOST("hiddenUserID") then
   rigLogMessage "error", "This form post did not pass the security check.", TRUE
  end if

  put rigVarPost("first") into tData["firstName"]
  put rigVarPost("last") into tData["lastName"]
  put rigVarPost("company") into tData["company"]
  put rigVarPost("phone") into tData["phone"]

  # UPDATE PASSWORD IF IT WAS POSTED
  if rigVarPost("password") <> empty then
   rigSetRules "password", "Password", \
"requiredR|minLengthR[" & tMinPasswordLength & "]|maxLengthR[" & tMaxPasswordLength & "]|matchesR[passwordConfirm]|xssClean"
   rigSetRules "passwordConfirm", "Confirm Password", "requiredR"

   put rigVarPost("password") into tData["password"]
  end if

  # FORM VALIDATION
  if rigFormValidRun("auth/editUser") is TRUE then
   get rigAuthUpdate(tUser["id"], tData)

   rigSetSessFlashdata "message", "User saved."
   # REDIRECT TO AUTH PAGE
   rigRedirect "auth/"
  end if

 end if -- if $_POST is an array then
 put rigValidationErrors("<div class=" & quote & "error" & quote & ">", "</div>") into tErrors
 if tErrors <> empty then
  put tErrors into gData["message"]
 else
  put rigSessFlashdata("message") into gData["message"]
  if gData["message"] is FALSE then
   put empty into gData["message"]
  end if
 end if

 # INPUT FIELDS
 put "first" into tInFirstArr["name"]
 # RE-POPULATE THE FIELD
 put rigSetValue("first", tUser["firstName"]) into tInFirstArr["value"]
 put "50" into tInFirstArr["maxlength"]
 put rigFormInput(tInFirstArr) into gData["first"]

 put "last" into tInLastArr["name"]
 # RE-POPULATE THE FIELD
 put rigSetValue("last", tUser["lastName"]) into tInLastArr["value"]
 put "50" into tInLastArr["maxlength"]
 put rigFormInput(tInLastArr) into gData["last"]

 put "company" into tInCompArr["name"]
 # RE-POPULATE THE FIELD
 put rigSetValue("company", tUser["company"]) into tInCompArr["value"]
 put "100" into tInCompArr["maxlength"]
 put rigFormInput(tInCompArr) into gData["company"]

 put "phone" into tInPhoneArr["name"]
 # RE-POPULATE THE FIELD
 put rigSetValue("phone", tUser["phone"]) into tInPhoneArr["value"]
 put "50" into tInPhoneArr["maxlength"]
 put rigFormInput(tInPhoneArr) into gData["phone"]

 put "password" into tInPassArr["name"]
 # RE-POPULATE THE FIELD
 put rigSetValue("password") into tInPassArr["value"]
 put "50" into tInPassArr["maxlength"]
 put rigFormInput(tInPassArr) into gData["password"]

 put "passwordConfirm" into tInPassConfArr["name"]
 # RE-POPULATE THE FIELD
 put rigSetValue("passwordConfirm") into tInPassConfArr["value"]
 put "50" into tInPassConfArr["maxlength"]
 put rigFormInput(tInPassConfArr) into gData["passwordConfirm"]

 put "hiddenUserID" into tInUserIdArr["name"]
 put tID into tInUserIdArr["value"]
 put "hidden" into tInUserIdArr["type"]
 put rigFormInput(tInUserIdArr) into gData["hiddenUserID"]

 # LOAD VIEW
 get rigLoadView("auth/editUserMainView")

end editUser
Top of Page

Now add the last handler which is needed to delete user data.

command deleteUser
 put "Auth Test Delete User" into gData["pageTitle"]

 put rigFetchSegment(3) into tID

 # FORM OPEN
 put "authForm" into tFormAttr["id"]
 put rigFormOpen("auth/deleteUser/" & tID, tFormAttr) into gData["formOpen"]

 # FIELD SET
 put rigFormFieldset("Delete User Form") into gData["fsOpen"]
 put rigFormFieldsetClose() into gData["fsClose"]

 # FORM LABELS
 put "formLabel" into tLabelAttr["class"]
 put rigFormLabel("Yes:", "confirm", tLabelAttr) into gData["confirmRadioYesLabel"]
 put rigFormLabel("No:", "confirm", tLabelAttr) into gData["confirmRadioNoLabel"]

 # SUBMIT
 put "deleteSubmit" into tSubmitArr["name"]
 put "Submit" into tSubmitArr["value"]
 put "submitBtn" into tSubmitArr["id"]
 put rigSubmitButton(tSubmitArr) into gData["deleteSubmit"]

 # FORM VALIDATION
 if rigFormValidRun("auth/deleteUser") is TRUE then
  put FALSE into tDeleted

  # CHECK IF DEACTIVATION WAS CONFIRMED
  if rigVarPOST("confirm") is "yes" then

   # VALIDATE THE REQUEST
   if tID <> rigVarPOST("id") then
    rigLogMessage "error", "This form post did not pass the security check.", TRUE
   end if

   # CHECK THE USER LEVEL
   if (rigAuthLoggedIn() is TRUE) and (rigAuthIsAdmin() is TRUE) then
    put rigAuthDeleteUser(tID) into tDeleted
   end if

  end if

  # GET AUTH MESSAGES AND REDIRECT TO THE AUTH PAGE
  if tDeleted is TRUE then
   put rigAuthMessages() into tMessages
  else
   put rigAuthErrors() into tMessages
  end if

  rigSetSessFlashdata "message", tMessages
  rigRedirect "/auth"

 else
  put rigValidationErrors("<div class=" & quote & "error" & quote & ">", "</div>") into tErrors
  if tErrors <> empty then
   put tErrors into gData["message"]
  else
   put rigSessFlashdata("message") into gData["message"]
   if gData["message"] is FALSE then
    put empty into gData["message"]
   end if
  end if

  # HIDDEN USER ID FIELD
  put rigAuthUser(tID) into tQueryResult

  if (tQueryResult <> FALSE) and (tQueryResult is an array) then
   put rigDbRow() into tUserRow
   put tUserRow["id"] into tUserID
   put tUserRow["username"] into gData["userName"]
  else
   put empty into tUserID
  end if
  put rigFormHidden("id", tUserID) into gData["hiddenUserID"]

  # RADIO BUTTONS
  put rigSetRadio("confirm", "yes") into gData["confirmYes"]
  put rigSetRadio("confirm", "no", TRUE) into gData["confirmNo"]

  # LOAD VIEW
  get rigLoadView("auth/deleteUserMainView")
 end if
end deleteUser






--| END OF auth.lc
--| Location: ./application/controllers/auth.lc
----------------------------------------------------------------------
Top of Page

The Form Validation File

The rules to validate authentication. Create a file called validation.lc. In it, place the code below and save it to your application/config/ folder.

<?lc

if gRigA is not an array then
  put "No direct script access allowed."
  exit to top
end if


local sValidationConf


# AUTHENTICATION VALIDATION
# LOGIN
rigAddValidationGrp "auth/login"
rigAddValidationRules "identity", "Email", "trim|requiredR|validEmailR|maxLengthR[100]|xssClean", sValidationConf
rigAddValidationRules "password", "Password", "requiredR|alphaDashR|maxLengthR[40]|xssClean", sValidationConf
rigAddValidationRules "remember[]", "Remember me", "numericR", sValidationConf


# CREATE USER
rigAddValidationGrp "auth/createUser"
rigAddValidationRules "first", "First Name", "trim|requiredR|minLengthR[3]|maxLengthR[50]|alphaDashR|xssClean", sValidationConf
rigAddValidationRules "last", "Last Name", "trim|requiredR|minLengthR[3]|maxLengthR[50]|alphaDashR|xssClean", sValidationConf
rigAddValidationRules "company", "Company", "trim|minLengthR[3]|maxLengthR[100]|alphaDashR|xssClean", sValidationConf
rigAddValidationRules "email", "Email", "trim|requiredR|validEmailR|minLengthR[3]|maxLengthR[100]|xssClean", sValidationConf
rigAddValidationRules "phone", "Phone", "trim|alphaDashR|maxLengthR[20]", sValidationConf
rigAddValidationRules "password", "Password", "requiredR|minLengthR[8]|maxLengthR[40]|matchesR[passwordConfirm]|xssClean", sValidationConf
rigAddValidationRules "passwordConfirm", "Confirm Password", "requiredR", sValidationConf


# DEACTIVATE USER
rigAddValidationGrp "auth/deactivate"
rigAddValidationRules "confirm", "Confirmation", "requiredR|alphaR", sValidationConf
rigAddValidationRules "id", "User ID", "requiredR|numericR", sValidationConf


# FORGOT PASSWORD
rigAddValidationGrp "auth/forgotPassword"
rigAddValidationRules "email", "Email", "trim|requiredR|validEmailR|minLengthR[3]|maxLengthR[100]|xssClean", sValidationConf


# RESET PASSWORD
rigAddValidationGrp "auth/resetPassword"
rigAddValidationRules "newPassword", "New Password", "requiredR|minLengthR[8]|maxLengthR[20]|matchesR[newPasswordConfirm]|xssClean", sValidationConf
rigAddValidationRules "newPasswordConfirm", "Confirm New Password", "requiredR", sValidationConf


# CHANGE PASSWORD
rigAddValidationGrp "auth/changePassword"
rigAddValidationRules "oldPassword", "Old Password", "requiredR", sValidationConf
rigAddValidationRules "newPassword", "New Password", "requiredR|minLengthR[8]|maxLengthR[20]|matchesR[newPasswordConfirm]|xssClean", sValidationConf
rigAddValidationRules "newPasswordConfirm", "Confirm New Password", "requiredR", sValidationConf


# EDIT USER
rigAddValidationGrp "auth/editUser"
rigAddValidationRules "first", "First Name", "trim|requiredR|minLengthR[3]|maxLengthR[50]|alphaDashR|xssClean", sValidationConf
rigAddValidationRules "last", "Last Name", "trim|requiredR|minLengthR[3]|maxLengthR[50]|alphaDashR|xssClean", sValidationConf
rigAddValidationRules "company", "Company", "trim|minLengthR[3]|maxLengthR[100]|alphaDashR|xssClean", sValidationConf
rigAddValidationRules "phone", "Phone", "trim|alphaDashR|maxLengthR[20]", sValidationConf
rigAddValidationRules "password", "Password", "minLengthR[8]|maxLengthR[40]|matchesR[passwordConfirm]|xssClean", sValidationConf
rigAddValidationRules "passwordConfirm", "Confirm Password", "minLengthR[8]", sValidationConf


# DELETE USER
rigAddValidationGrp "auth/deleteUser"
rigAddValidationRules "confirm", "Confirmation", "requiredR|alphaR", sValidationConf
rigAddValidationRules "id", "User ID", "requiredR|numericR", sValidationConf



function rigFetchValidationConf
 return sValidationConf
end rigFetchValidationConf



--| END OF validation.lc
--| Location: ./application/config/validation.lc
----------------------------------------------------------------------
Top of Page

The View Files

Create the following view files and save them to a folder called "auth" in your application/views/ folder.

We use multiple views nested in a parent view file. The header view, name it "headerView.lc", is included in all parent views (one fits all):

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">

  <title>[[gData["pageTitle"]]]</title>
  <? return rigCssAsset("authentication.css") ?>

</head>

The view which represents the admin page called "authView.lc":

<body>

  <div id="container" class="adminPage">
    <header>
      <h1>Users</h1>
    </header>

    <div id="main" role="main">


    <div id="infoMessage">[[gData["message"]]]</div>

      [[gData["usersTable"]]]

      <p>[[gData["newUserLink"]]]</p>

      <p>[[gData["logoutLink"]]]</p>

    </div>
  </div> <!--! end of #container -->

</body>
</html>  

The parent view of the admin page called "authMainView.lc":

<?
put rigLoadView("auth/headerView", TRUE) into tHeader
put rigLoadView("auth/authView", TRUE) into tContent
return tHeader && tContent
?>

The view used to change a password. It is called "changePasswordView.lc":

<body>

  <div id="container" class="changePassword">
    <header>
    <h1>Change Password</h1>
    </header>

    <div id="main" role="main">

    <div id="infoMessage">[[gData["message"]]]</div>


    [[gData["formOpen"]]]
    [[gData["fsOpen"]]]

    <div>[[gData["oldPasswordLabel"]]] [[gData["oldPassword"]]]</div>

    <div>[[gData["newPasswordLabel"]]] [[gData["newPassword"]]]</div>

    <div>[[gData["newPasswordConfirmLabel"]]] [[gData["newPasswordConfirm"]]]</div>

    [[gData["hiddenUserID"]]]


    <div>[[gData["changeSubmit"]]]</div>

    [[gData["fsClose"]]]
    </form>

    </div>
  </div> <!--! end of #container -->

</body>
</html>

"changePasswordMainView.lc", the parent view of the view above:

<?
put rigLoadView("auth/headerView", TRUE) into tHeader
put rigLoadView("auth/changePasswordView", TRUE) into tContent
return tHeader && tContent
?>

The "createUserView.lc" view:

<body>

  <div id="container" class="createUser">
    <header>
    <h1>Create User</h1>
    <p>Please enter the users information below.</p>
    </header>

    <div id="main" role="main">

      <div id="infoMessage">[[gData["message"]]]</div>

      [[gData["formOpen"]]]
      [[gData["fsOpen"]]]


      <div>[[gData["firstLabel"]]] [[gData["first"]]]</div>

      <div>[[gData["lastLabel"]]] [[gData["last"]]]</div>

      <div>[[gData["companyLabel"]]] [[gData["company"]]]</div>

      <div>[[gData["emailLabel"]]] [[gData["email"]]]</div>

      <div>[[gData["phoneLabel"]]] [[gData["phone"]]]</div>

      <div>[[gData["passwordLabel"]]] [[gData["password"]]]</div>

      <div>[[gData["passwordConfirmLabel"]]] [[gData["passwordConfirm"]]]</div>

      <div>[[gData["createSubmit"]]]</div>

    [[gData["fsClose"]]]
      </form>

      </div>
  </div> <!--! end of #container -->

</body>
</html>

The parent view "createUserMainView.lc":

<?
put rigLoadView("auth/headerView", TRUE) into tHeader
put rigLoadView("auth/createUserView", TRUE) into tContent
return tHeader && tContent
?>

The "deactivateUserView.lc" view:

<body>

  <div id="container" class="deactivate">
    <header>
      <h1>Deactivate User</h1>
      <p>Are you sure you want to deactivate the user '[[gData["userName"]]]'</p>
    </header>


    <div id="main" role="main">

    [[gData["formOpen"]]]
    [[gData["fsOpen"]]]

      [[gData["hiddenUserID"]]]
    <div>[[gData["confirmRadioYesLabel"]]] <input type="radio" name="confirm" value="yes" [[gData["confirmYes"]]] /></div>
    <div>[[gData["confirmRadioNoLabel"]]] <input type="radio" name="confirm" value="no" [[gData["confirmNo"]]] /></div>

     <div>[[gData["deactivateSubmit"]]]</div>

    [[gData["fsClose"]]]
    </form>
    </div>
  </div> <!--! end of #container -->

</body>
</html>

The parent view "deactivateUserMainView.lc":

<?
put rigLoadView("auth/headerView", TRUE) into tHeader
put rigLoadView("auth/deactivateUserView", TRUE) into tContent
return tHeader && tContent
?>

The "deleteUserView.lc" view:

<body>

  <div id="container" class="delete">
    <header>
      <h1>Delete User</h1>
      <p>Are you sure you want to delete the user '[[gData["userName"]]]'</p>
    </header>


  <div id="main" role="main">

  [[gData["formOpen"]]]
  [[gData["fsOpen"]]]

  [[gData["hiddenUserID"]]]
  <div>[[gData["confirmRadioYesLabel"]]] <input type="radio" name="confirm" value="yes" [[gData["confirmYes"]]] /></div>
  <div>[[gData["confirmRadioNoLabel"]]] <input type="radio" name="confirm" value="no" [[gData["confirmNo"]]] /></div>

  <div>[[gData["deleteSubmit"]]]</div>

  [[gData["fsClose"]]]
  </form>
  </div>
  </div> <!--! end of #container -->

</body>
</html>

The parent view "deleteUserMainView.lc":

<?
put rigLoadView("auth/headerView", TRUE) into tHeader
put rigLoadView("auth/deleteUserView", TRUE) into tContent
return tHeader && tContent
?>

The "editUserView.lc" view:

<body>

<div id="container" class="editUser">
   <header>
    <h1>Edit User</h1>
    <p>Please enter the users information below.</p>
   </header>

   <div id="main" role="main">

    <div id="infoMessage">[[gData["message"]]]</div>

    [[gData["formOpen"]]]
    [[gData["fsOpen"]]]


    <div>[[gData["firstLabel"]]] [[gData["first"]]]</div>

    <div>[[gData["lastLabel"]]] [[gData["last"]]]</div>

    <div>[[gData["companyLabel"]]] [[gData["company"]]]</div>

    <div>[[gData["phoneLabel"]]] [[gData["phone"]]]</div>

    <div>[[gData["passwordLabel"]]] [[gData["password"]]]</div>

    <div>[[gData["passwordConfirmLabel"]]] [[gData["passwordConfirm"]]]</div>

    [[gData["hiddenUserID"]]]

    <div>[[gData["editSubmit"]]]</div>

    [[gData["fsClose"]]]
    </form>

    </div>
  </div> <!--! end of #container -->

</body>
</html>

The parent view "editUserMainView.lc":

<?
put rigLoadView("auth/headerView", TRUE) into tHeader
put rigLoadView("auth/editUserView", TRUE) into tContent
return tHeader && tContent
?>

The "forgotPasswordView.lc" view:

<body>

  <div id="container" class="forgotPassword">
    <header>
    <h1>Forgot Password</h1>
    <p>Please enter your email address so we can send you an email to reset your password.</p>
    </header>

    <div id="main" role="main">

    <div id="infoMessage">[[gData["message"]]]</div>


    [[gData["formOpen"]]]
    [[gData["fsOpen"]]]

    <div>[[gData["emailLabel"]]] [[gData["email"]]]</div>

    <div>[[gData["forgotSubmit"]]]</div>

    [[gData["fsClose"]]]
    </form>

  </div>
  </div> <!--! end of #container -->

</body>
</html>

The parent view "forgotPasswordMainView.lc":

<?
put rigLoadView("auth/headerView", TRUE) into tHeader
put rigLoadView("auth/forgotPasswordView", TRUE) into tContent
return tHeader && tContent
?>

The "loginView.lc" view:

<body>

  <div id="container" class="login">
    <header>
      <h1>Login</h1>
      <p>Please login with your email/username and password below.</p>
    </header>

    <div id="main" role="main">
      <div id="infoMessage">[[gData["message"]]]</div>

    [[gData["formOpen"]]]
    [[gData["fsOpen"]]]

    <div>[[gData["identityLabel"]]] [[gData["identity"]]]</div>

    <div>[[gData["passwordLabel"]]] [[gData["loginPassword"]]]</div>

    <div>[[gData["rememberLabel"]]] <input type="checkbox" name="remember[]" value="1" [[gData["chbRemember"]]] /></div>

    <div>[[gData["loginSubmit"]]]</div>


    [[gData["fsClose"]]]
    </form>
  </div>
  </div> <!--! end of #container -->

</body>
</html>

The parent view "loginMainView.lc":

<?
put rigLoadView("auth/headerView", TRUE) into tHeader
put rigLoadView("auth/loginView", TRUE) into tContent
return tHeader && tContent
?>

The "resetPasswordView.lc" view:

<body>

  <div id="container" class="resetPassword">
      <header>
      <h1>Change Password</h1>
      </header>

    <div id="main" role="main">

  <div id="infoMessage">[[gData["message"]]]</div>


  [[gData["formOpen"]]]
  [[gData["fsOpen"]]]


  <div>[[gData["newPasswordLabel"]]] [[gData["newPassword"]]]</div>

  <div>[[gData["newPasswordConfirmLabel"]]] [[gData["newPasswordConfirm"]]]</div>

  [[gData["hiddenUserID"]]]


  <div>[[gData["resetSubmit"]]]</div>

  [[gData["fsClose"]]]
  </form>

  </div>
  </div> <!--! end of #container -->

</body>
</html>

The parent view "resetPasswordMainView.lc":

<?
put rigLoadView("auth/headerView", TRUE) into tHeader
put rigLoadView("auth/resetPasswordView", TRUE) into tContent
return tHeader && tContent
?>
Top of Page

The CSS File

Create a CSS file called authentication.css, in it place the following code and save it to your assets/css/ folder:

body {
  margin: 40px;
  padding: 0;
  font-family: "Lucida Grande", Lucida, Verdana, Geneva, Sans-serif;
  font-size: 12px;
  color: #888;
  background-color: #fff;
}
#container {
  margin-left: auto;
  margin-right: auto;
}
#container.login,
#container.editUser,
#container.createUser,
#container.changePassword,
#container.forgotPassword,
#container.resetPassword {
  width: 400px;
}
#container.adminPage {
  width: 610px;
}
#container.deactivate, #container.delete {
  width: 350px;
}
.formLabel {
  display: inline-block;
  width:  160px;
  margin-bottom: 10px;
}
table {
  width: 600px;
}
th {
  text-align: left;
}
button a {
  text-decoration: none;
}

Try it!

After having installed all those sample files