🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Simulate login
This page was created by Hans.karlsen on 2017-03-27. Last edited by Wikiadmin on 2026-07-29.

You can simulate a logged-in user in the MDriven Designer System Prototyper when you need to test logic that reads the current user without performing a real login.

What simulated login does

The System Prototyper does not identify a user or request credentials. To test user-dependent logic, set the CurrentUser on SysSingleton when the prototype starts.

SysSingleton is the application root object used to hold login information. CurrentUser is assigned a SysUser object from the model.

For example, if an action allows only the current user to see that user's records, simulating login as someusername lets you test that action in the prototyper.

Simulate a user at prototype startup

  1. Ensure that the model contains a SysUser with the username you want to test. The SysUserAuthentication pattern provides the SysUser class.
  2. Open the System Prototyper in MDriven Designer.
  3. Locate the Exp to run on start box.
  4. Enter an OCL expression that finds the user and assigns it to CurrentUser:
SysSingleton.oclSingleton.CurrentUser := SysUser.allinstances->select(username='someusername')->first
  1. Replace someusername with the username of the test user in your model.
  2. Start the prototype. The startup expression runs and your logic can read SysSingleton.oclSingleton.CurrentUser as the selected user.

How the expression works

Expression part Meaning
SysSingleton.oclSingleton Gets the singleton object that stores application-level login information.
SysUser.allinstances Gets the available SysUser objects.
->select(username='someusername') Selects users whose username equals the specified test value.
->first Uses the first selected user.
CurrentUser := ... Assigns that user as the prototype's current user.

Test user-specific logic

Use the simulated current user wherever your model logic needs to identify the user. For example, an expression can compare a record's user with the simulated user:

self.Owner = SysSingleton.oclSingleton.CurrentUser

Change the username in Exp to run on start and restart the prototype to test the same logic as another user.

Limits

This technique is for the MDriven Designer System Prototyper. It does not authenticate a password, create a web login session, or implement access control in a deployed Turnkey application.

For registration, password login, external login, and authorization in a Turnkey application, use SysUserAuthentication and the guidance in Turnkey user login. For programmatic login scenarios, see Log in with code.

See also