Login Screen for the Flexviewer

34678
121
03-15-2011 10:52 AM
andrewj_ca
Occasional Contributor II
Just posted some code for a Flexviewer login screen.  I hope somebody can get some use from this.

http://www.arcgis.com/home/item.html?id=baebcaf317994d63902bc9735c0657e0
Tags (2)
0 Kudos
121 Replies
RobertScheitlin__GISP
MVP Emeritus

Saurabh,

   I have updated by link in post 108 so that it links to the correct location in GeoNet.

0 Kudos
SaurabhGupta4
New Contributor

Robert

Thanks a lot for the reply

Regards

Saurabh

0 Kudos
tommykurniawan1
New Contributor III

Hi Forums,

One time i need to create simple login mechanism for flex viewer 3.6, i create it like this

-----

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

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

               xmlns:s="library://ns.adobe.com/flex/spark"

               xmlns:viewer="com.esri.viewer.*"

               xmlns:managers="com.esri.viewer.managers.*"

               pageTitle="ArcGIS Viewer for Flex">

    <fx:Style source="defaults.css"/>

    <fx:Metadata>

        [ResourceBundle("ViewerStrings")]

    </fx:Metadata>

   

    <fx:Script>

        <![CDATA[

            import mx.controls.Alert;

            import mx.managers.PopUpManager;

            protected function button1_clickHandler(event:MouseEvent):void

            {

                if(text1.text == "P4ssw0rd")

                {

                    Alert.show("Login success!");

                    viewerContainer.visible= true;   

                }

                else

                {

                    Alert.show("Login failed!");

                }

            }

        ]]>

    </fx:Script>

   

    <fx:Declarations>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

    </fx:Declarations>

    <s:Form id="form1" x="3" y="1" width="226" height="64">

        <s:TextInput id="text1" width="200" height="20" displayAsPassword="true" enabled="true"

                     prompt="Password"/>

        <s:Button left="60" width="100" height="20" label="Enter" click="button1_clickHandler(event)"/>

    </s:Form>   

    <viewer:ViewerContainer id="viewerContainer" visible="false"  x="0" y="0">

        <viewer:configManager>

            <managers:ConfigManager id="configManager"/>

        </viewer:configManager>

        <viewer:dataManager>

            <managers:DataManager id="dataManager"/>

        </viewer:dataManager>

        <viewer:mapManager>

            <managers:MapManager id="mapManager"/>

        </viewer:mapManager>

        <viewer:uiManager>

            <managers:UIManager id="uiManager"/>

        </viewer:uiManager>

        <viewer:widgetManager>

            <managers:WidgetManager id="widgetManager"/>

        </viewer:widgetManager>

    </viewer:ViewerContainer>

</s:Application>

---

type 'P4ssw0rd' for password, and press enter

works fine for me,

Regards - Tommy

0 Kudos
saurabhgupta2
New Contributor II

Hello everyone

I have applied the above code to get a login screen up and running

Thanks for this great work. But still i am searching how to load different config file according to role of the user

Thanks and regards

Saurabh

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Saurabh,

   The ability to have a certain config.xml based on the viewer that has logged in is part of the ArcGISSecurity web service found in this link:

https://community.esri.com/message/182812#182812

I am not sure which link you used to get your webservice for user validation but the one above uses a list of users names and passwords and the specific config to return once the user has successfully logged in.

0 Kudos
saurabhgupta2
New Contributor II

Robert

I have used the different one . I will try with the one you have provided ( devsummit 2012).

Just wanted to know ..

Can We some how pass the Username to my Main app to show which user have logged in ..something like" Welcome Username" . I have seen that some one has posted the same query but i guess it was not answered .

Regards

Saurabh

0 Kudos
saurabhgupta2
New Contributor II

Hello Robert

I have applied the code on IIS 8.5 ( gisbeta - /devsummit2012/ ). I got some error of duplicate records ( on line 14,16,17,18,19 of web.config) which i commented ( as i did in previous code  ) . After that i got directory browsing error which i resolved again. But now im getting this error. I have changed the line of username and password which u have mentioned earlier .

thanks and regards

Saurabh

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Saurabh,

  Here is a VS2013 version that uses .NET 4.5.1 (since you are one windows 8). You will need to change the wsdl url in the index.html from

ws.wsdl ="http://yourserver/ArcGIS_Security/Service.wsdl";

to

ws.wsdl ="http://yourserver/ArcGIS_Security/ValidateUser.svc?wsdl";

As far as your question about returning the logged in user name. That is done in the Flex Viewer Files\src\index.html included in the zip file I linked in the previous post.

0 Kudos
saurabhgupta2
New Contributor II

Robert

I will try to integrate this one and will post the result accordingly

Thanks and Regards

Saurabh

saurabhgupta2
New Contributor II

Robert

The service works fine but its not uploading different config file!! Am i missing something ?

I can see that service is returning the config file name from the xml but cant see any piece of code that uses the output config file except this one:

if(configFile != ""){

  var outArray:Array = configFile.split(",");

  usrConfigfile = outArray[0];

I am not able to get how to use this to load the specific config file

regards

Saurabh

0 Kudos