5 Replies Latest reply on Dec 20, 2008 3:17 AM by stinasius

    popup login

    stinasius Level 1
      hi guys need help on a login system in flex and coldfusion where by i have a main application with a view stack which has 2 views a home view and an admin view. when someone clicks on the admin view a popup login form appears and the they signin and if there is a success the admin view shows up in the viewstack. Bruce Phillips does not use a popup login form.
        • 1. Re: popup login
          Michael Borbor Level 4
          If you know how to create a cf/flex login now you need to learn about pop-ups this link could help you
          http://blog.flexexamples.com/2008/03/20/creating-custom-pop-up-windows-with-the-popupmanag er-class-redux/
          • 2. Re: popup login
            stinasius Level 1
            hi thats not what i wanted. i need to know how to go on and authenticate the the username and password match what is in the database and if yes the go ahead and change to admin view.
            • 3. popup login
              Probably this could be helpful. This is the code for the pop up form
              wherein the user needs to enter the username and password. Once you close the popup you can access the variables userId and passWd in the main application. Pass the parameters to the backend with Http Service or whatever and if the credentials are valid handle the result of the
              http service to make the admin view visible. One way to make admin view visible is , initially the canvas is disabled and when the user is authenticated successfully you can make the canvas in the viewstack enabled. Hope everything is clear and any doubts reply back.
              • 4. Re: popup login
                stinasius Level 1
                hi here is my code...please guide me on whta am doing wrong. the views dont change when i log in plus i dont think it works.


                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns:view="components.*">
                <mx:State name="Log Out">
                <mx:SetProperty target="{label1}" name="text" value="Log Out"/>
                import components.*;
                //Flash Classes
                import flash.events.Event;
                import flash.events.MouseEvent;

                //Flex Classes
                import mx.containers.TitleWindow;
                import mx.controls.Alert;
                import mx.events.CloseEvent;
                import mx.managers.PopUpManager;
                import mx.core.IFlexDisplayObject;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.remoting.RemoteObject;

                //variables that are used throughout the application
                public var username:String;
                public var password:String;

                public var loggedin:Boolean = false;
                public var pop:Login;

                private var ro:RemoteObject;
                public function createRemoteObjects () : void {
                //ro = new RemoteObject();
                ro.destination = "ColdFusion";
                ro.source = "login_example.cfc.login";
                ro.processLogin.addEventListener(ResultEvent.RESULT, processLoginHandler);
                ro.addEventListener(FaultEvent.FAULT, faultHandler);

                private function processLogin():void
                ro.loginUser(pop.username_txt.text, pop.password_txt.text);

                private function processLoginHandler(event:ResultEvent):void
                if(event.result as String == "Success!")
                viewstack1.selectedChild = admin;
                Alert.show("Login Failed!");
                pop.username_txt.text = "";
                pop.password_txt.text = "";

                private function faultHandler(fault:FaultEvent):void
                case "Client.Error.RequestTimeout":
                Alert.show("The server is not responding. Please check that you are connected and the server is running.", "Server Timeout");
                Alert.show(fault.fault.faultString, fault.fault.faultCode.toString());

                private function showLogin():void
                pop = Login(PopUpManager.createPopUp(this,Login,true));
                pop.showCloseButton =true;
                pop["cancelButton"].addEventListener("click", removeMe);

                private function removeMe(event:Event):void {


                <mx:Label x="0" y="0" text="Sign In" id="label1" buttonMode="true" useHandCursor="true" mouseChildren="false" click="showLogin()"/>
                <mx:ViewStack x="0" y="26" id="viewstack1" width="100%" height="100%">
                <view:Home id="home"/>
                <view:Admin id="admin"/>
                <mx:Label x="700" y="0" id="lbl_intro"/>


                <?xml version="1.0" encoding="utf-8"?>
                <mx:TitleWindow xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" title="Login Form">
                <mx:Form x="0" y="0">
                <mx:FormItem label="User Name:">
                <mx:TextInput id="username_txt"/>
                <mx:FormItem label="Password:">
                <mx:TextInput id="password_txt"/>
                <mx:HBox width="100%">
                <mx:Button label="Login" id="okButton"/>
                <mx:Spacer width="100%"/>
                <mx:Button label="Cancel" id="cancelButton"/>


                <cffunction name="loginUser" access="remote" returntype="boolean">
                <cfargument name="username" required="true" />
                <cfargument name="password" required="true" />
                <cfif (arguments.username EQ "a@...") AND (arguments.password EQ "xyz")>
                <cfreturn true>
                <cfreturn false>
                • 5. Re: popup login
                  stinasius Level 1
                  hi here is my code...please guide me on what am doing wrong. the views don't change when i log in plus i don't think it works.