Using your own user table in WebApps: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
m
Formatting changes.
(Minor edit)
m (Formatting changes.)
 
(2 intermediate revisions by 2 users not shown)
Line 3: Line 3:
Actually it is reasonably simple, but I'm going to go through it line-by-line, so it will seem like a lot, but it really isn't.
Actually it is reasonably simple, but I'm going to go through it line-by-line, so it will seem like a lot, but it really isn't.


The instructions below assume that your system has a user table; that it has a userID column of some sort; that column is the primary (unique) key; and that column is the sole element of Index.1 on that table. (If that last is <u>not</u> the case, you will have to also modify the "Send Find of hoUserDD EQ Index.1" line in the Userlogin procedure in your sub-class to use the correct index.)
The instructions below assume that your system has a user table; that it has a userID column of some sort; that column is the primary (unique) key; and that column is the sole element of Index.1 on that table. (If that last is <u>not</u> the case, you will have to also modify the "Send Find of hoUserDD EQ Index.1" line in the UserLogin procedure in your sub-class to use the correct index.)


Text in {''italics''} should be replaced with the appropriate values for your own system.
Text in {''italics''} should be replaced with the appropriate values for your own system.
Line 11: Line 11:
====Step 2. From {''DataFlexInstalledLocation''}\Pkg:====
====Step 2. From {''DataFlexInstalledLocation''}\Pkg:====


# Copy cWebSessionManagerStandard.pkg (note: <u>not</u> cWebSessionManager.pkg) to your AppSrc directory, renaming it to cWebSessionManager{''YourSystemName''}.pkg
# Copy [https://docs.dataaccess.com/dataflexhelp/mergedProjects/VDFClassRef/cWebSessionManagerStandard.htm cWebSessionManagerStandard.pkg] (note: <u>not</u> cWebSessionManager.pkg) to your AppSrc directory, renaming it to cWebSessionManager{''YourSystemName''}.pkg
# Copy cWebAppUserDataDictionary.pkg and cWebAppSessionDataDictionary.pkg to your DDSrc directory (the former will not actually be used, but will be modified by the next step of the process, so best to copy it too)
# Copy [https://docs.dataaccess.com/dataflexhelp/index.htm#t=mergedProjects%2FVDFClassRef%2FcWebAppUserDataDictionary.htm&rhsearch=cWebAppUserDataDictionary.pkg&rhhlterm=cWebAppUserDataDictionary.pkg&rhsyns=%20 cWebAppUserDataDictionary.pkg] and [https://docs.dataaccess.com/dataflexhelp/index.htm#t=mergedProjects%2FVDFClassRef%2FcWebAppSessionDataDictionary.htm&rhsearch=cWebAppSessionDataDictionary&rhhlterm=cWebAppSessionDataDictionary&rhsyns=%20 cWebAppSessionDataDictionary.pkg] to your DDSrc directory (the former will not actually be used, but will be modified by the next step of the process, so best to copy it too)


====Step 3. Change the relationship of WebAppSession to WebAppUser to point to your user table instead:====
====Step 3. Change the relationship of WebAppSession to WebAppUser to point to your user table instead:====
Line 21: Line 21:
====Step 4. Modify your cWebSessionManager sub-class:====
====Step 4. Modify your cWebSessionManager sub-class:====


#Change the use statement: "Use cWebSessionManager.pkg" to "Use cWebSessionManagerStandard.pkg"
#Change the use statement:<br /> "Use cWebSessionManager.pkg"<br /> to:<br />  "'''Use cWebSessionManagerStandard.pkg'''"  
#Replace the use statement: replace "Use cWebAppUserDataDictionary.dd" with "Use c{''YourUserTable''}DataDictionary.dd"
#Replace the use statement:<br /> "Use cWebAppUserDataDictionary.dd"<br /> with: <br />"'''Use c{''YourUserTable''}DataDictionary.dd'''"
#Change the classname: from "Class cWebSessionManagerStandard is a cWebSessionManager" to "Class cWebSessionManager{''YourSystemName''} is a cWebSessionManagerStandard" (so sub-classing cWebSessionManagerStandard)
#Change the classname:<br /> "Class cWebSessionManagerStandard is a cWebSessionManager" <br />to: <br />  "'''Class cWebSessionManager{''YourSystemName''} is a cWebSessionManagerStandard'''" (so sub-classing cWebSessionManagerStandard)
#Change the user data dictionary instance: in the '''Construct_Object''' procedure change "Get Create (RefClass(cWebAppUserDataDictionary)) to hoUserDD" to "Get Create (RefClass(c{''YourUserTable''}DataDictionary)) to hoUserDD"
#Change the user data dictionary instance: in the '''Construct_Object''' procedure <br />"Get Create (RefClass(cWebAppUserDataDictionary)) to hoUserDD" <br />to: <br />"'''Get Create (RefClass(c{''YourUserTable''}DataDictionary)) to hoUserDD'''"
#Modify the '''UserLogin''' function:
#Modify the '''UserLogin''' function:
##Replace the line: "Move sLoginName to WebAppUser.LoginName" with "Move sLoginName to {''YourUserTable''}.{''YourIdCol''}
##Replace the line: <br />"Move sLoginName to WebAppUser.LoginName" <br />with: <br />"'''Move sLoginName to {''YourUserTable''}.{''YourIdCol''}'''"
##Replace the line: "If (Found and (Lowercase(sLoginName) = Lowercase(Trim(WebAppUser.LoginName)))) Begin" with "If (Found and (Lowercase(sLoginName) = Lowercase(Trim({''YourUserTable''}.{''YourIdCol''})))) Begin"
##Replace the line: <br />"If (Found and (Lowercase(sLoginName) = Lowercase(Trim(WebAppUser.LoginName)))) Begin" <br />with: <br />"'''If (Found and (Lowercase(sLoginName) = Lowercase(Trim({''YourUserTable''}.{''YourIdCol''})))) Begin'''"
##Replace the line: "Get Field_Current_Value of hoUserDD Field WebAppUser.Password to sUserPassword" with "Get Field_Current_Value of hoUserDD Field {''YourUserTable''}.{''YourPasswordCol''} to sUserPassword"
##Replace the line: <br />"Get Field_Current_Value of hoUserDD Field WebAppUser.Password to sUserPassword"<br /> with: <br />"'''Get Field_Current_Value of hoUserDD Field {''YourUserTable''}.{''YourPasswordCol''} to sUserPassword'''"
##Replace the line: "Set Field_Changed_Value of hoUserDD Field WebAppUser.LastLogin to (CurrentDateTime())" with "Set Field_Changed_Value of hoUserDD Field {''YourUserTable''}.{''YourLastLoginCol''} to (CurrentDateTime())"  // This one is optional.  You may not have such a column (a date, by default) and if you do not wish to create one just remove the line
##Optional. Replace the line: <br />"Set Field_Changed_Value of hoUserDD Field WebAppUser.LastLogin to (CurrentDateTime())"<br /> with:<br /> "'''Set Field_Changed_Value of hoUserDD Field {''YourUserTable''}.{''YourLastLoginCol''} to (CurrentDateTime())'''"  // This one is optional because you may not have such a column (a date, by default) and if you do not wish to create one just remove the line.
#Modify the '''UpdateSessionProperties''' function:
#Modify the '''UpdateSessionProperties''' function:
##Replace the line "Set psUsername to (Trim(WebAppUser.FullName))" with "Set psUsername to (Trim({''YourUserTable''}.{''YourUserFullname''}))"  // Optional - otherwise just remove the line
##Optional - otherwise just remove the line. Replace the line:<br /> "Set psUsername to (Trim(WebAppUser.FullName))"<br /> with:<br /> "'''Set psUsername to (Trim({''YourUserTable''}.{''YourUserFullname''}))'''"   
##Replace the line "Set psLoginName to (Trim(WebAppUser.LoginName))" with "Set psLoginName to (Trim({''YourUserTable''}.{''YourIdColumn''}))
##Replace the line:<br /> "Set psLoginName to (Trim(WebAppUser.LoginName))"<br /> with: <br />"'''Set psLoginName to (Trim({''YourUserTable''}.{''YourIdColumn''}))'''"
##Replace the line: "Set piUserRights to WebAppUser.Rights" with "Set piUserRights to {''YourUserTable''}.{''YourRightsColumn''}  // Optional - if you don't have a rights column, remove the line.  Note: if you use an ASCII column, rather than a numeric one for this, you will need to add a different property in the Construct_Object procedure of the class - something like "Property String psUserType" and "Set" that instead
##Optional - if you don't have a rights column, remove the line. Replace the line:<br /> "Set piUserRights to WebAppUser.Rights"<br /> with:<br /> "'''Set piUserRights to {''YourUserTable''}.{''YourRightsColumn''}'''" //   '''Note:''' if you use an ASCII column, rather than a numeric one for this, you will need to add a different property in the Construct_Object procedure of the class - something like "Property String psUserType" and "Set" that instead
#Remove all the other methods from your sub-class (they are covered in its super-class cWebSessionManagerStandard):
#Remove all the other methods from your sub-class (they are covered in its super-class cWebSessionManagerStandard):
##CreateSession
##CreateSession
Line 45: Line 45:
====Step 5.  Modify SessionManager.wo to use your sub-class:====
====Step 5.  Modify SessionManager.wo to use your sub-class:====


#Change: "Use cWebSessionManagerStandard.pkg" to "Use cWebSessionManager{''YourSystemName''}.pkg"
#Change:<br /> "Use cWebSessionManagerStandard.pkg"<br /> to:<br /> "'''Use cWebSessionManager{''YourSystemName''}.pkg'''"
#Change: "Object oSessionManager is a cWebSessionManagerStandard" to "Object oSessionManager is a cWebSessionManager{''YourSystemName''}"
#Change:<br /> "Object oSessionManager is a cWebSessionManagerStandard" <br />to:<br /> "'''Object oSessionManager is a cWebSessionManager{''YourSystemName''}'''"


Now you should be good to go and users of your Windows app will/can also be users of your WebApp!
Now you should be good to go and users of your Windows app will/can also be users of your WebApp!
[[Category: Web Applications]]

Navigation menu