Logging onto VLF-ONE without entering a user and password

This forum allows developers to post programming tips and coding techniques that may be useful to other Visual LANSA developers. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
MarkD
Posts: 630
Joined: Wed Dec 02, 2015 9:56 am

Logging onto VLF-ONE without entering a user and password

Post by MarkD » Mon Aug 15, 2016 9:27 am

If you are developing a VLF-ONE application then having to continuously enter your credentials can become onerous.

Here's a way to enter them automatically and avoid the log on dialog.

Create a new reusable part named MYLOGON (say).

In your custom VLF-ONE entry point form, copied from UF_OEXEC, nominate MYLOGON in the LogonHandlerId() parameter, instead of VF_AC026O.

Code: Select all

#VLF_ONE.uInitialize ……………….. LogonHandlerId(MYLOGON) ……………..………… 
Put this code into MYLOGON and change user and password where indicated ………………..

Code: Select all

Begin_Com Role(*EXTENDS #VF_AC026O)
Define_Com Class(#PRIM_TIMR) Name(#LogonShortDelayTimer) Interval(1) Startup(Manual)
* ------------------------------------------------------------
Evtroutine Handling(#LogonShortDelayTimer.Tick)
#LogonShortDelayTimer.Stop
* Replace TheUser and ThePassword with valid credentials.
Signal Event(LogOnAttemptRequested) Platformu(TheUser) Platformp(ThePassword)
Endroutine
* ------------------------------------------------------------
* Handle getting required user profile and password
Mthroutine Name(uRequestPlatformUCredentials) Options(*REDEFINE)
Define_Com Class(#Prim_Boln) Name(#AtEntry_FrameworkLoadListAttempted)
* Track what the framework list load attempt flag says at entry
#AtEntry_FrameworkLoadListAttempted := #FrameworkListLoadAttempted
* Do ancestor processing
#Com_Ancestor.uRequestPlatformUCredentials Templogonmanager(#TempLogonManager) Attemptedrequests(#AttemptedRequests)
* No log on form is to be visible
#Com_Owner.Visible := False
* If the frameworks list still needs to be loaded return control and wait for
* that to happen. When it does happen this method will be called again.
If (#AtEntry_FrameworkLoadListAttempted = False)
Return
Endif
* There is only one automatc attempt allowed otherwise bad values will get stuck in a loop
If (#AttemptedRequests > 1)
#uSystem.IssueTextMessage Text('The server has rejected your logon request. Check the user and password used.') Collectionnumber(1)
#uSystem.SignalRequestExit Possibletocancel(False) Browserisclosing(False)
Return
Endif
* If we reach here then start the log on a slight delay
#LogonShortDelayTimer.Start
Endroutine

End_Com

MarkD
Posts: 630
Joined: Wed Dec 02, 2015 9:56 am

Re: Logging onto VLF-ONE without entering a user and password

Post by MarkD » Wed Jun 26, 2019 10:25 am

Here is the latest version of the preceding logic:

Code: Select all

Begin_Com Role(*EXTENDS #VF_AC026O)
Define_Com Class(#PRIM_TIMR) Name(#LogonShortDelayTimer) Interval(1) Startup(Manual)
* ------------------------------------------------------------
Evtroutine Handling(#LogonShortDelayTimer.Tick)
#LogonShortDelayTimer.Stop
* Replace TheUser and ThePassword with valid credentials.
Signal Event(LogOnAttemptRequested) Platformu(THEUSER) Platformp(THEPASSWORD)
Endroutine
* ------------------------------------------------------------
* Handle getting required user profile and password
Mthroutine Name(zInt_RequestPlatformUCredentials) Options(*REDEFINE)
Define_Com Class(#Prim_Boln) Name(#AtEntry_FrameworkLoadListAttempted)
* Track what the framework list load attempt flag says at entry
#AtEntry_FrameworkLoadListAttempted := #FrameworkListLoadAttempted
* Do ancestor processing
#Com_Ancestor.zInt_RequestPlatformUCredentials Attemptedrequests(#AttemptedRequests)
* No log on form is to be visible
#Com_Owner.Visible := False
* If the frameworks list still needs to be loaded return control and wait for
* that to happen. When it does happen this method will be called again.
If (#AtEntry_FrameworkLoadListAttempted = False)
Return
Endif
* There is only one automatc attempt allowed otherwise bad values will get stuck in a loop
If (#AttemptedRequests > 1)
#uSystem.zInt_IssueTextMessage Text('The server has rejected your logon request. Check the user and password used.') Collectionnumber(1)
#uSystem.zInt_SignalRequestExit Possibletocancel(False) Browserisclosing(False) Timeoutinprogress(False) Fatalerror(True)
Return
Endif
* If we reach here then start the log on a slight delay
#LogonShortDelayTimer.Start
Endroutine

End_Com

mwilliams
Posts: 12
Joined: Sat May 28, 2016 1:45 am

Re: Logging onto VLF-ONE without entering a user and password

Post by mwilliams » Sat Aug 03, 2019 3:48 am

Hey Mark,

I was trying to incorporate the code that you provided and I get a javascript error as soon as I click on anything after my app loads. Just clicking on anywhere causes the error. If I change the login handler back to the VF_AC026O in my launch page it all works again. Here is the error. I was wondering if you had any thought as to why this might be happening.
Attachments
2019_08_02_12_42_11_SD_One_Framework.png
2019_08_02_12_42_11_SD_One_Framework.png (23.19 KiB) Viewed 659 times

MarkD
Posts: 630
Joined: Wed Dec 02, 2015 9:56 am

Re: Logging onto VLF-ONE without entering a user and password

Post by MarkD » Mon Aug 05, 2019 10:51 am

It works okay for me in a system that I think is identical to yours.

We can try a few more things before it needs to go via support.

Look at your C:\Program Files (x86)\<LANSA System>\X_WIN95\X_LANSA\web\vl folder, and delete all folders except for lansa_14_2_4_1.

Recompile your entry point form and the 'logon avoidance' reusable part.

Clear you browser cache.

Try again.

MarkD
Posts: 630
Joined: Wed Dec 02, 2015 9:56 am

Re: Logging onto VLF-ONE without entering a user and password

Post by MarkD » Mon Aug 05, 2019 10:54 am

Failing that, add these lines to the logon avoidance reusable part:

Evtroutine Handling(#COM_OWNER.CreateInstance)
Set Com(#Com_Owner #InputPlatformU_MD #INPUTPLATFORMU #InputPlatformP_MD #INPUTPLATFORMP) Visible(False)
Endroutine

Recompile it, clear your browser cache, and try again.

BTW - Did you ever install any beta or pre-release versions of VL-Web or of VLF?
If yes, did you replace them with the final GA versions, including partition the required VLF initialization?

mwilliams
Posts: 12
Joined: Sat May 28, 2016 1:45 am

Re: Logging onto VLF-ONE without entering a user and password

Post by mwilliams » Fri Aug 16, 2019 6:35 am

Hey Mark,

I tried both your suggestions and neither seemed to work. And as far as I know, I have never installed a beta release. I'm sure it's something that I'm doing wrong. I'm trying to recreate the process you outlined in post viewtopic.php?f=3&t=2109&p=5646. I created a lansa web page using #PRIM_WEB that I placed before our original launch page because we needed additional information at login time. Basically what my login page does is validate the user id and password and then it retrieves any environments the user may be authorized to since we have customers that have multiple environments set up. once we get the environment, we can then override to the correct axes project and set the library list in our server modules. The login page does a Web.Navigate to our original launch page with the extra query string parm GUID and tries to bypass the launch page login screen and go straight to the login validater. All that seems to work like you outlined, but then I get my java script error as soon as I click anything.

Here is my login page that I created. It's ugly at the moment but I was just trying to get it working.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)

Define_Com Class(#PRIM_VS.Style) Name(#ThinBorders) Borderbottom(1) Borderleft(1) Borderright(1) Bordertop(1)

Define_Com Class(#PRIM_PANL) Name(#MainPanel) Displayposition(1) Height(473) Left(484) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(104) Width(300) Style(#ThinBorders)

Define_Com Class(#PRIM_MD.Dropdown) Name(#EnvDropDown) Caption('Environments') Displayposition(1) Left(8) Parent(#MainPanel) Tabposition(1) Top(272) Width(273) Visible(False)

Define_Com Class(#PRIM_MD.Edit) Name(#UserProfile) Appearance(TextFieldBox) Caption('User Name') Displayposition(2) Left(8) Parent(#MainPanel) Tabposition(2) Top(136) Width(273)

Define_Com Class(#PRIM_MD.Edit) Name(#UserPassword) Displayposition(3) Left(8) Parent(#MainPanel) Passwordchar('*') Tabposition(3) Top(200) Width(273) Caption('Password')

Define_Com Class(#PRIM_MD.FlatButton) Name(#Button) Caption('CANCEL') Displayposition(4) Left(155) Parent(#MainPanel) Tabposition(4) Themedrawstyle('Borders1') Top(336) Height(49) Width(131)

Define_Com Class(#PRIM_MD.FlatButton) Name(#Button1) Caption('SIGN IN') Displayposition(5) Left(8) Parent(#MainPanel) Tabposition(5) Themedrawstyle('Borders1') Top(336) Height(49) Width(121)

Define Field(#lastSlash) Type(*INT)
Define Field(#queryStringIdx) Type(*INT)
Def_List Name(#EnvList) Fields(#STD_TEXT) Counter(#STD_COUNT) Type(*WORKING) Entrys(*MAX)



Mthroutine Name(Navigate)
Define_Com Class(#SD1_LoginFormServerModule.GenerateGuid) Name(#guid)

#STD_TEXTS := #UserProfile.Value.UpperCase
#guid.ExecuteAsync Userprofile(#STD_TEXTS) Guid(#STD_TEXTL)

Evtroutine Handling(#Guid.Completed)
Define_Com Class(#PRIM_DC.UnicodeString) Name(#urlPrefix)
Define_Com Class(#PRIM_DC.UnicodeString) Name(#urlSuffix)

#lastSlash := #SYS_WEB.URL.LastPositionOf( '/' )
#queryStringIdx := #SYS_WEB.URL.LastPositionOf( '?' )

#urlPrefix := #SYS_WEB.URL.Substring( 1 #lastslash )
#urlSuffix := #SYS_WEB.URL.Substring( #queryStringIdx )

#SYS_WEB.Navigate Target(Current) Url(#urlPrefix + 'SD1_LAUNC.html' + #urlSuffix + '&ENV=' + #EnvDropDown.Value + '&GUID=' + #STD_TEXTL)

Endroutine
Endroutine

Mthroutine Name(GetEnvironments)
Define_Com Class(#SD1_LoginFormServerModule.GetUserEnvironments) Name(#GetEnvs)

Define Field(#u) Type(*CHAR) Length(10)
#u := #UserProfile.Value.UpperCase

#GetEnvs.ExecuteAsync Vlfuser(#u) Vlfenv(#EnvList)
Evtroutine Handling(#GetEnvs.Completed)
#EnvDropdown.Items.RemoveAll

Selectlist Named(#EnvList)
#EnvDropdown.Items.Add( #STD_TEXT )
Endselect

#EnvDropdown.Visible := TRUE
Endroutine

Evtroutine Handling(#GetEnvs.Failed) Reason(#Reason)
#SYS_WEB.Alert Caption(#Reason)
Endroutine

Endroutine

Mthroutine Name(ValidatePassword)
Define_Com Class(#SD1_LoginFormServerModule.ValidateUser) Name(#Validate)
Define Field(#p) Type(*CHAR) Length(10)

#u := #UserProfile.Value.UpperCase
#p := #UserPassword.Value.UpperCase
#Validate.ExecuteAsync Vlfuser(#u) Vlfpassword(#p) Status(#VF_ELRETC)
Evtroutine Handling(#Validate.Completed)
If (#VF_ELRETC = OK)
#COM_OWNER.GetEnvironments
Else
#EnvDropdown.Items.RemoveAll
#EnvDropdown.Visible := FALSE
Endif

Endroutine

Evtroutine Handling(#Validate.Failed) Reason(#Reason)
#SYS_WEB.Alert Caption(#Reason)
Endroutine

Endroutine

Evtroutine Handling(#Com_owner.Initialize)
Define Field(#w) Type(*INT)
Define Field(#h) Type(*INT)
Define Field(#cw) Type(*INT)
Define Field(#ch) Type(*INT)

#w := #SYS_WEB.WebPage.Width
#h := #SYS_WEB.WebPage.Height
#cw := #MainPanel.Width
#ch := #MainPanel.Height

#MainPanel.Left := (#w - #cw) / 2
#MainPanel.Top := (#h - #ch) / 2
Endroutine

Evtroutine Handling(#Button1.Click)
If (#EnvDropdown.Value ^= *blanks)
#COM_OWNER.Navigate
Return
Endif

#Com_Owner.ValidatePassword

Endroutine
End_Com

MarkD
Posts: 630
Joined: Wed Dec 02, 2015 9:56 am

Re: Logging onto VLF-ONE without entering a user and password

Post by MarkD » Mon Aug 19, 2019 9:43 am

Have you tried the preceding example without your extra login form in front of it (i.e. As a straight through no dialog logon)?
You might have to temporarily alter the server side validation to let you in.

Does that work with the strange error?

MarkD
Posts: 630
Joined: Wed Dec 02, 2015 9:56 am

Re: Logging onto VLF-ONE without entering a user and password

Post by MarkD » Mon Aug 19, 2019 9:43 am

Have you tried the preceding example without your extra login form in front of it (i.e. As a straight through no dialog logon)?
You might have to temporarily alter the server side validation to let you in.

Does that work with the strange error?

mwilliams
Posts: 12
Joined: Sat May 28, 2016 1:45 am

Re: Logging onto VLF-ONE without entering a user and password

Post by mwilliams » Mon Aug 19, 2019 12:11 pm

Hey Mark, I just tried your suggestion. I modified my login validater to set the output parms and just return OK. Went straight to the original launch page and I still get the javascript error.

MarkD
Posts: 630
Joined: Wed Dec 02, 2015 9:56 am

Re: Logging onto VLF-ONE without entering a user and password

Post by MarkD » Tue Aug 20, 2019 12:02 pm

Using this code:

Code: Select all

Begin_Com Role(*EXTENDS #VF_AC026O)
Define_Com Class(#PRIM_TIMR) Name(#LogonShortDelayTimer) Interval(1) Startup(Manual)
* ------------------------------------------------------------
Evtroutine Handling(#LogonShortDelayTimer.Tick)
#LogonShortDelayTimer.Stop
* Replace TheUser and ThePassword with valid credentials.
Signal Event(LogOnAttemptRequested) Platformu(THEUSER) Platformp(THEPASSWORD)
Endroutine
* ------------------------------------------------------------
* Handle getting required user profile and password
Mthroutine Name(zInt_RequestPlatformUCredentials) Options(*REDEFINE)
Define_Com Class(#Prim_Boln) Name(#AtEntry_FrameworkLoadListAttempted)
* Track what the framework list load attempt flag says at entry
#AtEntry_FrameworkLoadListAttempted := #FrameworkListLoadAttempted
* Do ancestor processing
#Com_Ancestor.zInt_RequestPlatformUCredentials Attemptedrequests(#AttemptedRequests)
* No log on form is to be visible
#Com_Owner.Visible := False
* If the frameworks list still needs to be loaded return control and wait for
* that to happen. When it does happen this method will be called again.
If (#AtEntry_FrameworkLoadListAttempted = False)
Return
Endif
* There is only one automatc attempt allowed otherwise bad values will get stuck in a loop
If (#AttemptedRequests > 1)
#uSystem.zInt_IssueTextMessage Text('The server has rejected your logon request. Check the user and password used.') Collectionnumber(1)
#uSystem.zInt_SignalRequestExit Possibletocancel(False) Browserisclosing(False) Timeoutinprogress(False) Fatalerror(True)
Return
Endif
* If we reach here then start the log on a slight delay
#LogonShortDelayTimer.Start
Endroutine

End_Com

and changing the server validation routine to unconditionally let you in, two different people here have run this and cannot reproduce your error.

You can start the application directly via UF_OEXEC or DF_OEXEC and sign on without seeing the dialogue, and you can execute things once started.

If this is exactly what you did to start out - then I think the only recourse now is to report the issue to support with all version details, etc.

If this is not exactly what you did to start out - could you see if this simplest possible case works for you.

mwilliams
Posts: 12
Joined: Sat May 28, 2016 1:45 am

Re: Logging onto VLF-ONE without entering a user and password

Post by mwilliams » Wed Aug 21, 2019 1:29 am

Hey Mark,

what I'm doing is exactly like what you are describing. Our launch page is just like UF_OEXEC and my handler is exactly like the code that you posted. The problem seems to be the browser. We've been experiencing different behavior with javascript within aXes between browsers so I just tried using FireFox instead of Google Chrome and it worked perfectly. I also tried it with Microsoft Edge and that worked as Well.

The version of Google Chrome that I'm using is version 76.0.3809.100 (Official Build) (64-bit).

MarkD
Posts: 630
Joined: Wed Dec 02, 2015 9:56 am

Re: Logging onto VLF-ONE without entering a user and password

Post by MarkD » Wed Aug 21, 2019 10:21 am

I just tried it again with the same Chrome version and it works as expected.
Capture.PNG
Capture.PNG (13.26 KiB) Viewed 531 times
You might try clearing the Chrome cache and have one more try.
Failing that, I have no other ideas.

I think this now needs to go to LANSA support.

mwilliams
Posts: 12
Joined: Sat May 28, 2016 1:45 am

Re: Logging onto VLF-ONE without entering a user and password

Post by mwilliams » Fri Aug 30, 2019 9:53 am

hey Mark, I discovered something with this issue that you may be able to point me in the right direction. When I log in to my custom login form and navigate to our original launch page that now has the login handler if I don't touch(click) anything in the browser window I get the javascript error. But if I log in and as the loading wheel is spinning I click anywhere in the browser then all is fine and I do not get the javascript error and everything seems to run just fine. I was wondering if you may have any ideas on what I could try? It's like something needs focus or something.

mwilliams
Posts: 12
Joined: Sat May 28, 2016 1:45 am

Re: Logging onto VLF-ONE without entering a user and password

Post by mwilliams » Fri Aug 30, 2019 2:44 pm

One final thought. I tried my app from my home pc using chrome which has the same version and everything worked fine. I can only assume it has something to do with chrome on my work pc. I'm going to try and uninstall and reinstall tomorrow to see if that fixes my issue.

Post Reply