project BLF > class TDaemon > method DaemonLogin
Description
Login with daemon user login. The inherited method will expect a company-code added to the icExtra (BEFORE the Ancestor-code)
Parameters
| icLogin | input | character | Login |
| icPassword | input | character | password |
| icExtra | input | character | Extra (Password is encoded, company code, ...) |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program1/tdaemon.p)
assign viSessionId = viSession1ID.
/* ================================================================= */
/* Check if the selected user is linked to all existing companies */
/* 1. fetch all companies */
/* 2. fetch the companies that are linked to the selected user */
/* 3. Check if user has all companies linked */
/* --> if not --> Error */
/* ================================================================= */
if vcAction = "Start"
then do:
/* Get All Active Companies */
<Q-6 run CompanyByDomainActive (all) (Read) (NoCache)
(input ?, (CompanyId)
input ?, (DomainId)
input True, (CompanyIsActive)
output dataset tqCompanyByDomainActive) in BCompany >
/* Get All Companies linked to the user in UsrCompany */
<Q-10 run UserCompanies (all) (Read) (NoCache)
(input icLogin, (UserLogin)
input ?, (CyId)
input ?, (DomainId)
output dataset tqUserCompanies) in BUser >
/* Set language code, unless already defined with -lng startup parameter */
if current-language = ""
or current-language = ?
or current-language = "?"
then do:
find first tqUserCompanies no-error.
if available tqUserCompanies
then current-language = tqUserCompanies.tcLngCode.
end.
/* Check if each active company is linked to the user */
For each tqCompanyByDomainActive
break by tqCompanyByDomainActive.tcCompanyCode:
/* Fill in icExtra */
if first(tqCompanyByDomainActive.tcCompanyCode)
then assign icExtra = icExtra + chr(2) + 'CompanyCode':U + chr(2) + tqCompanyByDomainActive.tcCompanyCode.
/* Check User has access to this company */
if not can-find(tqUserCompanies where
tqUserCompanies.tiCompany_ID = tqCompanyByDomainActive.tiCompany_ID)
then do:
assign oiReturnStatus = -1.
<M-19 run SetMessageInLog
(input #T-20'The selected user should be linked to all entities.':100(389)T-20# (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TDaemon>
return.
end. /* not can-find(tqUserCompanies ...) */
end. /* for each tqCompanyByDomainActive */
empty temp-table tqCompanyByDomainActive.
empty temp-table tqUserCompanies.
end. /* vcAction = "Start" */
<M-1 run Login
(input icLogin (icLogin),
input icPassword (icPassword),
input icExtra (icExtra),
output vlValid (olValid),
output oiReturnStatus (oiReturnStatus)) in Session>
if not vlValid or
oiReturnStatus < 0
then do :
<M-2 run SetMessageInLog
(input substitute(trim(#T-3'Cannot start a session for daemon &1. Unable to log in.':120(80)T-3#),vcCurrentDaemon ) (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TDaemon>
return.
end.