1 Reply Latest reply on Jul 16, 2007 9:47 AM by ntsiii

    send Password Reminder

    James Bower Level 1
      Hi,
      I 'm trying to get this to work but so far nothing's happening when I click "Get Password"

      Here's my mxml file.

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Form xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" width="100%" height="100%">

      <mx:Metadata>
      [Event("remindersent")]
      [Event("login")]
      </mx:Metadata>

      <mx:Script>
      <![CDATA[
      import mx.events.ValidationResultEvent;
      import mx.rpc.events.ResultEvent;
      import mx.utils.ObjectUtil;
      import mx.controls.Alert;
      import mx.rpc.events.FaultEvent;


      private function isValid():Boolean
      {
      var emailValidResult:ValidationResultEvent = this.emailValidate.validate(this.email.text);

      if (emailValidResult.type==ValidationResultEvent.VALID)
      {
      return true;
      }
      else
      {
      return false;
      }

      }


      private function remindUser():void
      {
      if( isValid() )
      {
      authManager.sendPasswordReminder( this.email.text );
      }
      }

      public function serverFault(event:FaultEvent):void
      {
      this.loginError.text = event.message['message'];
      this.loginError.height = 15;
      this.loginError.visible = true;
      }

      private function sendReminder_result(event:ResultEvent):void
      {
      this.dispatchEvent( new Event('remindersent') );
      }
      ]]>
      </mx:Script>

      <mx:RemoteObject
      id="authManager"
      destination="ColdFusion"
      source="ArtistWork.components.cfgenerated.managers.Auth">
      <mx:method name="sendPasswordReminder" result="sendReminder_result(event)" fault="serverFault(event)" />
      </mx:RemoteObject>



      <mx:EmailValidator
      id="emailValidate"
      source="{this.email}"
      property="text"
      required="true" />

      <mx:Text width="100%" height="50"
      text="Instructions: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. " />

      <mx:Text id="loginError" visible="true"
      color="red" width="100%" height="15" />


      <mx:FormItem width="100%" label="Email" required="true" paddingLeft="10">
      <mx:TextInput id="email"
      width="175"/>
      </mx:FormItem>
      <mx:VBox width="100%" horizontalAlign="right">
      <mx:Button label="Get Password" click="remindUser()"/>

      <mx:LinkButton label="Login"
      click="this.dispatchEvent(new Event('login'))"
      fontStyle="italic" width="100" textAlign="right"/>
      </mx:VBox>

      </mx:Form>

      here's my CFC: Auth.cfc

      <cfcomponent>


      <cffunction name="sendPasswordReminder" access="remote" returntype="any">

      <cfquery name="rsGetPw" datasource="resumes">
      SELECT Email, FirstName, LastName, Username, Password
      FROM dbo.Employees
      WHERE Email = '#attributes.emailaddress#'
      </cfquery>
      <!--- If there is no matching record display an error --->
      <cfif rsGetPw.RecordCount EQ 0>
      <cfset request.PWNotFound = "Sorry, no matching record was found. Please try again.">
      <cfelse>

      <cfmail to="#rsGetPw.FirstName# #rsGetPw.LastName#<#rsGetPw.Email#>"
      from="#Myself#<#myemail@mydomain.com#>"
      subject="Your #Employee# log on."
      server="#mail.mymailserver.com#">

      Hello #rsGetPw.FirstName# #rsGetPw.LastName#,
      Here is your username and password...

      Username: #rsGetPw.Username#
      Password: #rsGetPw.Password#

      Thank you!

      ---

      </cfmail>
      <!--- Let the user know that the password has been found and sent --->
      <cfset request.PWFound = "Your username and password have been sent to #rsGetPw.Email#.<br>If this email address is no longer accessible you will need to contact customer service.">
      </cfif>
      <cfreturn true>
      </cffunction>


      </cfcomponent>

      What am I missing?