Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfcomponent displayname="User" output="false">
- <cfproperty name="UserId" displayname="UserId" hint="Unique id for the user." type="numeric" />
- <cfproperty name="FirstName" displayname="FirstName" hint="First name of the User" type="string" />
- <cfproperty name="LastName" displayname="LastName" hint="Last name of the user." type="string" />
- <cfproperty name="Email" displayname="Email" hint="User's email." type="string" />
- <cfproperty name="Salt" displayname="Salt" hint="User's salt." type="string" />
- <cfproperty name="Password" displayname="Password" hint="User's password." type="string" />
- <cffunction name="init" access="public" output="false" returntype="User">
- <cfargument name="UserId" required="false" type="numeric" default="0" hint="Primary Key" />
- <cfargument name="FirstName" required="true" type="string" hint="User first name" />
- <cfargument name="LastName" required="true" type="string" hint="User last name" />
- <cfargument name="Email" required="true" type="string" hint="User email" />
- <cfargument name="Salt" required="false" type="string" hint="Salt to seure the password" />
- <cfargument name="Password" required="true" type="string" hint="User password" />
- <cfset variables.instance = structNew() />
- <cfset setUserId(arguments.UserId) />
- <cfset setFirstName(arguments.FirstName) />
- <cfset setLastName(arguments.LastName) />
- <cfset setEmail(arguments.Email) />
- <cfif NOT ISNULL(arguments.Salt) >
- <cfset setSalt(arguments.Salt) />
- </cfif>
- <cfset setPassword(arguments.Password) />
- </cffunction>
- <cffunction name="getUserId" access="public" output="false" returntype="numeric">
- <cfreturn variables.instance.UserId />
- </cffunction>
- <cffunction name="setUserId" access="public" output="false" returntype="void">
- <cfargument name="argUserId" type="numeric" required="true" />
- <cfset variables.instance.UserId=argUserId />
- </cffunction>
- <cffunction name="getFirstName" access="public" output="false" returntype="string">
- <cfreturn variables.instance.FirstName />
- </cffunction>
- <cffunction name="setFirstName" access="public" output="false" returntype="void">
- <cfargument name="argFirstName" type="string" required="true" />
- <cfset variables.instance.FirstName=argFirstName />
- </cffunction>
- <cffunction name="getLastName" access="public" output="false" returntype="string">
- <cfreturn variables.instance.LastName />
- </cffunction>
- <cffunction name="setLastName" access="public" output="false" returntype="void">
- <cfargument name="argLastName" type="string" required="true" />
- <cfset variables.instance.LastName=argLastName />
- </cffunction>
- <cffunction name="getEmail" access="public" output="false" returntype="string">
- <cfreturn variables.instance.Email />
- </cffunction>
- <cffunction name="setEmail" access="public" output="false" returntype="void">
- <cfargument name="argEmail" type="string" required="true" />
- <cfset variables.instance.Email=argEmail />
- </cffunction>
- <cffunction name="getSalt" access="public" output="false" returntype="string">
- <cfreturn variables.instance.Salt />
- </cffunction>
- <cffunction name="setSalt" access="public" output="false" returntype="void">
- <cfargument name="argSalt" type="string" required="true" />
- <cfset variables.instance.Salt=argSalt />
- </cffunction>
- <cffunction name="getPassword" access="public" output="false" returntype="string">
- <cfreturn variables.instance.Password />
- </cffunction>
- <!--- TODO CHECK IF THERE IS A SALT...IF NOT MAKE ONE AND HASH THE PASSWORD.
- CHECK IF YOU'RE CHANGING THE PASSWORD TO RESALT IT. --->
- <cffunction name="setPassword" access="public" output="false" returntype="void">
- <cfargument name="argPassword" type="string" required="true" />
- <cfset variables.instance.Password=argPassword />
- </cffunction>
- </cfcomponent>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement