Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: 1 [2]
16  Announcements and General Discussion / Getting Started / Question about startup on: June 02, 2008, 05:31:45
I'm not sure if I am thinking about this correctly or approaching it the correct way but here is what I am trying to accomplish:

I am using AMFPHP, Flex and puremvc of course

I am implementing user authentication and want to emulate user sessions in flex

When a user logs in to the Flex application I set a session var for the user in AMFPHP. Then if the user reloads the page with the flex application I want to detect that the user is already authenticated and instead of taking them to the loginView stack I want them to go directly to the applicationView stack.

I have logging in and out functional.

I also have a button on my loginView that triggers the loginMediator to checkSession. Upon success the view stack is changed to the application, upon failue the view stack is changed to the login. This button works.

I have a sendNotification in my StartupCommand. This is suppose to send a notification to the loginMediator to checkSession which handles sending the notification to update the viewstack. But this notification never is received and I have put everything to handle the notification in loginMediator.

How can I make sure that checkSession is automatically called right after the application loads?

Any help is appreciated. TIA,
Shinan
17  Announcements and General Discussion / Getting Started / Re: Newbie Question about Proxys and User Authentication on: May 29, 2008, 05:35:13
Yes, indeed. That occurred to me late yesterday after pouring through the forums and documentation. It worked. It is all starting to make more sense to me now.

Thanks Cliff for pureMVC and for taking the time to help us newbies out in the forums.

I appreciate it.

Regards.
18  Announcements and General Discussion / Getting Started / Newbie Question about Proxys and User Authentication on: May 28, 2008, 11:50:33
I am finally starting to get my application off the ground. I am still trying to wrap my heard around all this since I am new to puremvc and flex.

I am authenticating a user using a remoteobject.

All that works, I am able to authenticate and change my viewstack if the authentication is successful.

On my view that is displayed after the user logs in I want to display a simple "Welcome, <username>"

How do I access my user object from an arbitrary view?

Here is my code for the loginProxy:
:
public class LoginProxy extends Proxy implements IProxy
{
public static const NAME:String = "LoginProxy";

private var loginService:RemoteObject;

public function LoginProxy( data:Object = null ){
super(NAME, data);

}

public function userLogin(username:String,password:String):void {
loginService = new RemoteObject();
loginService.source = "org.enohp.app.Userdao";
loginService.destination = "userService";
loginService.addEventListener( FaultEvent.FAULT, onFault );
loginService.getUserFromLogin.addEventListener( ResultEvent.RESULT, onResult );
loginService.getUserFromLogin.send(username,password);
}

private function onResult( event:ResultEvent ):void {
if (!event.result) {
Alert.show("You have entered an invalid username/password", "Login Error");
} else {
setData(event.result as User);
Alert.show("You have successfully logged in.", "Login Success");
sendNotification( ApplicationFacade.VIEW_FBAPP );
}
}

private function onFault(fault:FaultEvent):void {
Alert.show(fault.fault.faultString + "\n" + fault.fault.faultDetail, fault.fault.faultCode.toString());
}

public function get user():User
{
return data as User;
}
}

The loginProxy is called from a notification that is handled by my loginMediator:

:
private function onMouseClick(e:Event):void {
loginProxy.userLogin(theView.username.text,theView.password.text);
Alert.show(ObjectUtil.toString(loginProxy.getData()), "Login User from Login Mediator");
}

I thought  that my alert in the mediator should show the user that was authenticated but it returns null.

Any help is appreciated.

TIA,
Shinan
Pages: 1 [2]