Advertisement
eldieck

User Object

Apr 24th, 2017
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <cfcomponent displayname="User" output="false">
  2.    
  3.     <cfproperty name="UserId" displayname="UserId" hint="Unique id for the user." type="numeric" />
  4.     <cfproperty name="FirstName" displayname="FirstName" hint="First name of the User" type="string" />
  5.     <cfproperty name="LastName" displayname="LastName" hint="Last name of the user." type="string" />
  6.     <cfproperty name="Email" displayname="Email" hint="User's email." type="string" />
  7.     <cfproperty name="Salt" displayname="Salt" hint="User's salt." type="string" />
  8.     <cfproperty name="Password" displayname="Password" hint="User's password." type="string" />
  9.    
  10.     <cffunction name="init" access="public" output="false" returntype="User">
  11.         <cfargument name="UserId" required="false" type="numeric" default="0" hint="Primary Key" />
  12.         <cfargument name="FirstName" required="true" type="string" hint="User first name" />
  13.         <cfargument name="LastName" required="true" type="string" hint="User last name" />
  14.         <cfargument name="Email" required="true" type="string" hint="User email" />
  15.         <cfargument name="Salt" required="false" type="string" hint="Salt to seure the password" />
  16.         <cfargument name="Password" required="true" type="string" hint="User password" />
  17.        
  18.         <cfset variables.instance = structNew() />
  19.        
  20.         <cfset setUserId(arguments.UserId) />
  21.         <cfset setFirstName(arguments.FirstName) />
  22.         <cfset setLastName(arguments.LastName) />
  23.         <cfset setEmail(arguments.Email) />
  24.        
  25.         <cfif NOT ISNULL(arguments.Salt) >
  26.             <cfset setSalt(arguments.Salt) />
  27.         </cfif>
  28.        
  29.         <cfset setPassword(arguments.Password) />
  30.        
  31.     </cffunction>
  32.  
  33.     <cffunction name="getUserId" access="public" output="false" returntype="numeric">
  34.         <cfreturn variables.instance.UserId />
  35.        
  36.     </cffunction>
  37.  
  38.     <cffunction name="setUserId" access="public" output="false" returntype="void">
  39.         <cfargument name="argUserId" type="numeric" required="true" />
  40.         <cfset variables.instance.UserId=argUserId />
  41.        
  42.     </cffunction>
  43.  
  44.     <cffunction name="getFirstName" access="public" output="false" returntype="string">
  45.         <cfreturn variables.instance.FirstName />
  46.        
  47.     </cffunction>
  48.  
  49.     <cffunction name="setFirstName" access="public" output="false" returntype="void">
  50.         <cfargument name="argFirstName" type="string" required="true" />
  51.         <cfset variables.instance.FirstName=argFirstName />
  52.        
  53.     </cffunction>
  54.  
  55.     <cffunction name="getLastName" access="public" output="false" returntype="string">
  56.         <cfreturn variables.instance.LastName />
  57.        
  58.     </cffunction>
  59.  
  60.     <cffunction name="setLastName" access="public" output="false" returntype="void">
  61.         <cfargument name="argLastName" type="string" required="true" />
  62.         <cfset variables.instance.LastName=argLastName />
  63.        
  64.     </cffunction>
  65.  
  66.     <cffunction name="getEmail" access="public" output="false" returntype="string">
  67.         <cfreturn variables.instance.Email />
  68.        
  69.     </cffunction>
  70.  
  71.     <cffunction name="setEmail" access="public" output="false" returntype="void">
  72.         <cfargument name="argEmail" type="string" required="true" />
  73.         <cfset variables.instance.Email=argEmail />
  74.        
  75.     </cffunction>
  76.  
  77.     <cffunction name="getSalt" access="public" output="false" returntype="string">
  78.         <cfreturn variables.instance.Salt />
  79.        
  80.     </cffunction>
  81.  
  82.     <cffunction name="setSalt" access="public" output="false" returntype="void">
  83.         <cfargument name="argSalt" type="string" required="true" />
  84.         <cfset variables.instance.Salt=argSalt />
  85.        
  86.     </cffunction>
  87.  
  88.     <cffunction name="getPassword" access="public" output="false" returntype="string">
  89.         <cfreturn variables.instance.Password />
  90.        
  91.     </cffunction>
  92.  
  93.     <!--- TODO CHECK IF THERE IS A SALT...IF NOT MAKE ONE AND HASH THE PASSWORD.
  94.     CHECK IF YOU'RE CHANGING THE PASSWORD TO RESALT IT. --->
  95.  
  96.     <cffunction name="setPassword" access="public" output="false" returntype="void">
  97.         <cfargument name="argPassword" type="string" required="true" />
  98.         <cfset variables.instance.Password=argPassword />
  99.        
  100.     </cffunction>
  101.  
  102. </cfcomponent>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement