Hi Guys, 

I'm building a 'create user' CFC, and, while it works, I'm wondering if I'm 
approaching it correctly. I've created a compact version of the format I'm 
using. I basically cut out all but a single argument so the code was easier 
to see in full. 

I have it split up into sections

1) Arguments
2) Declare local var structure
3) Declare return var structure 
4) validate arguments
5) if errors, skip step 6
6) If no errors, attempt to create user
7) return results


Does this look ok? 




<cffunction name="userCreate" hint="creates user" returntype="struct" 
output="no" access="remote" returnformat="json">
  <!--- arguments --->
  <cfargument name="email" type="string" required="true" default="" 
hint="user's email" />


  <!--- declare local variables / non returned data --->
  <cfset var local = StructNew()>
  <cfset local.email = "#arguments.email#">
  <cfset local.userSalt = "">
  <cfset local.userSaltHash = "">
  <cfset local.folderID = "">


  <!--- declare returned variables needed --->
  <cfset userCreateResults = StructNew()>
  <cfset userCreateResults.error = 0>
  <cfset userCreateResults.userID = "">
  <cfset userCreateResults.emailNotEmptyError = 0>


  <!--- validate provided arguments --->
  <cfif trim(local.email) eq "">
    <cfset userCreateResults.error = 1>
    <cfset userCreateResults.emailNotEmptyError = 1>
  </cfif>

  <!--- Attempt to create user if no errors raised --->
  <cfif userCreateResults.error eq 0>
    <!--- do work here --->
  </cfif>


  <cfreturn userCreateResults>
    
</cffunction>

-- 
-- 
online documentation: http://openbd.org/manual/
 http://groups.google.com/group/openbd?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Open 
BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to