6 Replies Latest reply on Feb 8, 2010 8:35 PM by disabled_uqkhurle

    Relogin IWP

    general

      Title

      Relogin IWP

      Post

      Hello,

       

      I am trying to write a script that requires a re-authentication before allowing access to a record/ layout that is also IWP compatible.  I found this works best by splitting the script into two parts:

       

      part a, re-directs to a layout where users are prompted to input username & password;

      part b, executed when user hits "submit" button on layout (grabs username and password and re-logs in using those values) then redirects to desired record/ layout.

       

      I'm having an issue if the re-login fails. I'll get the error message: "The account name and password you entered does not match any for those in any Filemaker account."  But, it still executes the next part of the script: "Go to Layout [LayoutName]."  This is not the desired action.

       

      Is there a way to capture the result of the relogin?  Is there a better way to do this for IWP?

       

      I essentially want users in IWP to re-authenticate prior to making changes to records. 

       

      Thanks...

        • 1. Re: Relogin IWP
          general
            

          Sorry, hit send to quickly... forgot to add:

           

          Using FM10 [Trial], but own FM9 Pro.

          Mac OS 10.5.8

          • 2. Re: Relogin IWP
            philmodjunk
              

            Try using Get ( LastError ) in an if step immediately after the re-login step.

             

            If [ get ( LastError ) ≠ 0 ]

             

            #put steps here to respond to incorrect account name or password

             

            Else

             

            #put code here for correct account/password

             

            End IF

            • 3. Re: Relogin IWP
              general
                

              PhilModJunk,

               

              Thanks for the help!  It works perfectly!

               

              general 

              • 4. Re: Relogin IWP
                AAgraphics
                  

                General,

                I have been trying to do something like what you are doing for quite some time.  Could you post both of the scripts you have, part A and part B?  Thanks! 

                • 5. Re: Relogin IWP
                  general
                    

                  AAgraphics,

                   

                  Sorry, just now saw your reply.

                   

                  Here are my scripts...

                   

                  Essentially, users are asked to re-authenticate when they want to edit a record.  There are two duplicate layouts, a view only "Layout" and an editable version "Layout edit".  The relogin layout is based on the table employees.  This table has some fields that are used solely for passing through information in the script (I don't want to use global variables or pay for FM Server).  This script is probably very bush league, and looking at it now can be cleaned up a little.

                   

                  =============== 

                   

                  web relogin edit part a 

                   

                  If [ Get ( LastError ) = 0 ]

                  Set Variable [$layout_name; Value:LayoutName]  // This is a variable that sets the pre-determined destination layout.

                  Set Variable [$record_target; Value:Get ( RecordNumber )] // This is a variable that sets the pre-determined destination record.

                  Perform Script ["omit records by username"] // This omits records in an employee table that do not match current username.

                  Go to Layout ["relogin for web" (employees)] // This is a layout based on the employee table that accepts the password.

                  Open Record/Request

                  Replace Field Contents [No Dialog; employees::password shell; ""]

                  Go to Field [employees::password shell]

                  Set Field [employees::layout target; $layout_name]

                  Set Field [employees::record target; $record_target]

                  Else

                  Exit Script []

                  End If

                   

                  ===============

                   

                  web relogin edit part b

                   

                  Commit Records/Requests [Skip data entry validation; No dialog]

                  Re-Login [Account Name: employees::username; Password: employees::password shell; No dialog]

                  If [Get ( LastError ) =/= 0]  // What happens if there is an error.

                  Go to Layout ["relogin for web" (employees)]

                  Open Record/Request

                  Replace Field Contents [No dialog; employees::password shell; ""]

                  Go to Field [employees::password shell]

                  Else // What happens if there is not an error.

                  Set Field [employees::password shell; ""] // Resets password shell field so passwords are not stored.

                  Set Variable [$layout_target; Value:employees::layout target]

                  Set Field [employees::layout target; ""]  // Resets layout target field so layout targets are not stored.

                   

                  Set Variable [$record_target; Value:employees::record target]

                  Set Field [employees::record target; ""]  // Resets record target field so record targets are not stored.

                  Go to Layout [$layout_target]

                  Go to Record/Request/Page [No dialog; $record_target]

                  Omit Multiple Record [No dialog; Get ( Record Number ) =/= $record_target]

                  End If 

                   

                  • 6. Re: Relogin IWP
                       Hi General, thanks so very much for sharing this.  What a wonderful discussion group this is.  Your message was extremely helpful.  Many many thanks!