Thanks, glad to help. Sorry for the delay in a reply, I've been offline most of the week. In case you haven't already figured this out I'll answer anyways.
 
 
>Wouldn't the CFLOGIN have to within the IF statement?
Becuase if the user isn't found in the database then there is no need to
set CFLOGIN at all right?
 
If I remember the code I sent you correctly (already deleted the email), then yes. Only call CFLOGIN if you found the user and they are a valid use.
 
>If my auth.cfc method login sends a value of FALSE as the
return value, then wouldn't my on Fault event come into play? Or would
it just be the Result variable?
 
If you return True/False, then the value is returned into the onResult handler as a valid result. In order for the onFault to get triggered you need to use <CFTHROW> and throw a real error. No which way should you do it? That's up to you. You can return true/false and use an if/else in your onResult. Or return true or throw an error.
 
Or do a 3rd option (I think this one). Return the user object of the authenticated user, if successful. And you can use this object to get the users name, preferences, etc.. And if the login is not successful throw a real error and handle it in your onFault method.
 
hth,
---nimer

----- Original Message ----
From: envidobi <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, September 11, 2006 2:52:20 PM
Subject: [flexcoders] Re: Using Auth.cfc from CF Wizard

Nimer,
Thanks for your help! I'm a big fan of your books btw!
So i tried to put your CFLOGIN code in play, but i can still get to the
main a pplication. Wouldn't the CFLOGIN have to within the IF statement?
Becuase if the user isn't found in the database then there is no need to
set CFLOGIN at all right? Also, i think what i get confused with flex is
with events. If my auth.cfc method login sends a value of FALSE as the
return value, then wouldn't my on Fault event come into play? Or would
it just be the Result variable? If so, wouldn't i have to put a more
detialed if statment within the login_result function of Login.mxml?

Here is the code from that file:
<?xml version="1.0" encoding="utf- 8"?>

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

<mx:Metadata>
[Event("forgotpassw ord")]
[Event("loginSucces sful")]
</mx:Metadata>

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

private var lso:SharedObject;

private function initApp():void
{
this.lso = SharedObject. getLocal( "auth");

if( this.lso.data[ 'user'] != null )
{
this.user.text = this.lso.data[ 'user'];
this.rememberLogin. selected = true;
}
if( this.lso.data[ 'password' ] != null )
{
this.password. text = this.lso.data[ 'password' ];
this.rememberLogin. selected = true;
}
}

private function isValid():Boolean
{
var pswdValidResult: ValidationResult Event =
this.pswdValidate. validate( this.password. text);

if (pswdValidResult. type==Validation ResultEvent. VALID)
{
return true;
}
else
{
return false;
}

}

private function authenticateUser( ):void
{
if( isValid() )
{
authManager. login( this.user.text,
this.password. text );
}
}

private function errorMessage( msg:String) :void
{
//Alert.show( ObjectUtil.toString (event.message) );
this.errorMsg. text = msg;
this.errorMsg. height = 15;
this.errorMsg. visible = true;
}

private function serverFault( event:FaultEvent ):void
{
errorMessage( event.message[ 'message' ]);
}

private function login_result( event:ResultEven t):void
{
// login successful, remember the user.
if( Boolean(event. result))
{
if( this.rememberLogin. selected )
{
this.lso.data[ 'user'] = this.user.text;
this.lso.data[ 'password' ] = this.password. text;
}
else
{
this.lso.data[ 'user'] = null;
this.lso.data[ 'password' ] = null;
}

this.dispatchEvent( new Event('loginSuccess ful') );
}
else
{
// login didn't work. show message
errorMessage( "Login unsuccessful" );
}
}
]]>
</mx:Script>

<mx:RemoteObject
id="authManager"
destination= "ColdFusion"

source="Tiomkin. Tiomkin_Admin. components. cfgenerated. managers. Auth"
showBusyCursor= "true">
<mx:method name="login" result="login_ result(event) "
fault="serverFault( event)" />
</mx:RemoteObject>

<mx:StringValidator
id="pswdValidate"
source="{this. password} "
property="text"
required="true" />

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

<mx:FormItem width="100%" label="User Name" required="true" >
<mx:TextInput id="user"
width="175"/ >
</mx:FormItem>
<mx:FormItem width="100%" label="Password" required="true" >
<mx:TextInput id="password"
displayAsPassword= "true"
width="175"/ >
</mx:FormItem>
<mx:FormItem>
<mx:CheckBox id="rememberLogin"
label="Remember Login"
selected="false" />
</mx:FormItem>

<mx:VBox width="100%" horizontalAlign= "right">
<mx:Button label="Login" click="authenticate User();"/ >
<mx:LinkButton label="Forgot Password?"
click="this. dispatchEvent( new Event('forgotpasswo rd'));"
fontStyle="italic" width="150" textAlign="right" />
</mx:VBox>

</mx:Form>

So should there be something like this:
private function login_result( event:ResultEven t):void
{
// login successful, remember the user.
if( Boolean(event. result) && event.result == true)
{
if( this.rememberLogin. selected )
{
this.lso.data[ 'user'] = this.user.text;
this.lso.data[ 'password' ] = this.password. text;
}
else
{
this.lso.data[ 'user'] = null;
this.lso.data[ 'password' ] = null;
}

this.dispatchEvent( new Event('loginSuccess ful') );
}
else
{
// login didn't work. show message
errorMessage( "Login unsuccessful" );
this.currentState= 'login';"

}
}

Like i said i get really confused with events, and i've been reading a
ton but its still fuzzy to me at this point, but i need to have this
application secure. Greatly appreciate your help! :)
thanks again
David


__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to