Skip to main content

system.kanoa.operators.operatorLogin(sessionInfo, userId)

Logs an operator into an asset by inserting an open mes.operatorAssetSession row. There is no separate operator identity - sessionInfo['userId'] is the sec.user being logged in, FK'd straight into sec.user. It can differ from the outer userId param (the actor performing the action, used for createdBy/changedBy audit) - e.g. a supervisor badging an operator in at a shared kiosk session. A filtered unique index blocks a duplicate open session for the same user+asset pair - if the user is already logged into this asset, the insert fails and this returns (None, message). By default (allowMultiSession not True), any OTHER open session this user has on a different asset is closed first (tStamp used as the logoutTStamp), so badging into a new line implicitly logs them out of the old one - the common case, and it avoids a user silently appearing 'logged in' on two lines at once because they forgot to badge out. Pass allowMultiSession=True to opt out (e.g. a floater/lead genuinely covering two assets).


Parameters

sessionInfo Dictionary

- allowMultiSessionBooleanoptional, default False
- assetIdInteger
- tStampString
- userIdIntegerthe sec.user being logged in
- workOrderIdIntegeroptional

userId Integer: the actor performing this action (createdBy/changedBy)


Returns

operatorAssetSessionId Integer the new session's id on success, None on failure
message String None on success, an error message on failure


Example

sessionInfo = {
'userId': 5,
'assetId': 4,
'workOrderId': None,
'tStamp': system.date.now(),
'allowMultiSession': False
}
userId = 12
operatorAssetSessionId, message = system.kanoa.operators.operatorLogin(sessionInfo, userId)