Here is some code I wrote today due to a request by a client to stop allowing 
users to remember their password when using the built in 4D user login window. 
This is that “Remember password” checkbox that you can’t make go away. The 
workaround is to just delete the file that stores the user name and password 
that is remembered. 

There is an article in the 4D Knowledge Base about this, but it is for older 
versions of 4D where the path to this saved “.mdp” file has different. I used 
that as a starting point and the got it to work with the 4D v14 version that I 
needed. Should work with 4D v14+. 

Works on macOS and Windows. You do need to provide the “application name” 
because I could not reliably determine this with so many possible variations 
like: using 4D, using merged single-user application, using merged client 
application or user has changed the application name. 

  // ===========================================
  // PROJECT METHOD: RemoveRememberedPassword

  // PARAMETERS: $1 = application name

  // DESCRIPTION: When using the 4D password system
  // you can choose the "Remember password" option which 
  // will save your username and password. This will allow 
  // you to bypass the login prompt and automatically log in from then on.

  // When the "Remember Password" option is selected, the 4D user name
  // and password are saved to a file. File name is the application name+".mdp"
  // This method will delete that file, if it exists.

  // Should work with 4D v14+ versions. (Unless they change the location, 
again.)

  // Windows path
  //     C:\Users\{username}\AppData\Roaming\{applicationName}\Favorites 
v{applicationMajorVersion}\Remote\

  // macOS Path
  //     /users/{username}/Library/Application 
Support/{applicationName}/Favorites v{applicationMajorVersion}/Remote/

  // CREATED BY: Tim Nevels, Innovative Solutions ©2018
  // DATE: 8/22/18
  // LAST MODIFIED: 
  // ============================================
C_TEXT($1;$applicationName_t)
$applicationName_t:=$1

  // declare local variables
C_TEXT($applicationMajorVersion_t;$filePath_t)

  // get 4D application major version
$applicationMajorVersion_t:=Substring(Application version;1;2)

  // strip off extension
If (<>macOS)
   $applicationName_t:=Replace string($applicationName_t;".app";"")
Else 
   $applicationName_t:=Replace string($applicationName_t;".exe";"")
End if 

  // build file path to the .mdp file
$filePath_t:=Get 4D folder(Active 4D Folder)+"Favorites 
v"+$applicationMajorVersion_t+Folder separator+\
   "Remote"+Folder separator+$applicationName_t+".mdp"

  // delete file if it is there
If (Test path name($filePath_t)=Is a document)
   DELETE DOCUMENT($filePath_t)
End if 


Tim

*****************************************
Tim Nevels
Innovative Solutions
785-749-3444
[email protected]
*****************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to