Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. define(
  2. [
  3. '../system/jobFactory',
  4. '../services/metadata',
  5. '../services/data',
  6. '../services/dataExecution',
  7. '../services/dataAcquisition',
  8. '../services/hrcDataAcquisition',
  9. '../services/adhocDataAcquisition',
  10. '../services/dataExport',
  11. '../security/authentication',
  12. '../system/frontEndLogger',
  13. '../security/connections',
  14. '../services/properties',
  15. '../services/config',
  16. '../db/db',
  17. '../system/packetFactory',
  18. '../services/fileReader',
  19. '../system/modulify',
  20. '../system/logger2',
  21. '../security/externalLogin',
  22. '../security/sanitizer',
  23. '../integration/scheduler'
  24. ],
  25. function(
  26. jobs,
  27. metadata,
  28. data,
  29. dataExecution,
  30. dataAcquisition,
  31. hrcDataAcquisition,
  32. adhocDataAcquisition,
  33. dataExport,
  34. authentication,
  35. frontEndLogger,
  36. connections,
  37. properties,
  38. config,
  39. db,
  40. packetFactory,
  41. fileReader,
  42. modulify,
  43. logger,
  44. externalLogin,
  45. sanitizer,
  46. scheduler
  47. ) {
  48. return modulify({
  49. endpoints: {
  50. /******** DATA *********/
  51. dataExecution: dataExecution.queue.bind(dataExecution),
  52. dataAcquisition: dataAcquisition.queue.bind(dataAcquisition),
  53. hrcDataAcquisition: hrcDataAcquisition.queue.bind(hrcDataAcquisition),
  54. setParameter: data.setParameter.bind(data),
  55. adhocDataAcquisition: adhocDataAcquisition.queue.bind(adhocDataAcquisition),
  56. dataExport: dataExport.queue.bind(dataExport),
  57.  
  58. /******** PROPERTIES*********/
  59. getTypeProperties: properties.getTypeProperties.bind(properties),
  60.  
  61. /******** CONNECTIONS*********/
  62. closePrc: connections.closePrc.bind(connections),
  63. openIpl: connections.openIpl.bind(connections),
  64. closeIpl: connections.closeIpl.bind(connections),
  65. showIpl: connections.showIpl.bind(connections),
  66. hideIpl: connections.hideIpl.bind(connections),
  67. reconnect: connections.reconnect.bind(connections),
  68.  
  69. /******** ???????????*********/
  70. remoteDataAcquisition: data.remoteDataAcquisition.bind(data),
  71. /******** Integration*********/
  72. extLogin: externalLogin.refreshConnectObjects.bind(externalLogin),
  73. extValToken: externalLogin.checkTokenTable.bind(externalLogin),
  74. /******* METADATA*******/
  75. getMetadata: metadata.getMetadata.bind(metadata),
  76.  
  77. login: authentication.initializeLicense.bind(authentication),
  78. register: authentication.register.bind(authentication),
  79. updatePassword: authentication.updatePassword.bind(authentication),
  80. getOrgGroups: authentication.getOrgGroups.bind(authentication),
  81. getImgFileList: fileReader.getImgFileList.bind(fileReader),
  82. uploadImage: fileReader.uploadImage.bind(fileReader),
  83. validateLicense: authentication.validateLicense.bind(authentication),
  84.  
  85. /******* ERROR LOGGER *******/
  86. logError: frontEndLogger.logError.bind(frontEndLogger),
  87.  
  88. /******* USER TRACKER *********/
  89. subscribeToMessages: userTracker.subscribe.bind(userTracker),
  90.  
  91. /******** INTEGRATION *********/
  92. scheduleIntegration: scheduler.schedule.bind(scheduler)
  93. },
  94. route: function(socket, msg) {
  95. //TODO: Do we need to save the last action timestamp here?
  96. var endpoint = this.endpoints[msg.endpoint];
  97.  
  98. if (!endpoint) {
  99. logger.error('NO ENDPOINT !!! THIS Should never happen - !@!!!!@@@#@$@#');
  100. return;
  101. }
  102. sanitizer.sanitizeData(msg.data);
  103. msg.data.socket = socket;
  104. msg.data.fromClient = true;
  105.  
  106. // check if the users session is still valid
  107. // update the last action timestamp
  108. // is the session has expired redirect the user to the login screen
  109. var user = connections.getConnectionFromSocket(socket.id);
  110. if (user.authenticated) {
  111. //TODO: Change this to use a job and the que
  112. var spOptions = {
  113. spName: 'inf_pcd_aut_ssn_chk',
  114. spPars: {
  115. usr: user.usr,
  116. org: user.org,
  117. grp: user.grp,
  118. token: user.token,
  119. que: 0
  120. }
  121. };
  122. db.executeProcedure(spOptions, this.onSessionChecked.bind(this, endpoint, msg, socket, user));
  123. } else {
  124. jobs.startJob(endpoint, msg.data, msg.callback, user);
  125. }
  126.  
  127. },
  128. onSessionChecked: function(endpoint, msg, socket, user, result) {
  129. if (result[0][0].sessionExpired == 1) {
  130. socket.emit('response', packetFactory.buildPacket({
  131. type: 'handshake',
  132. data: null,
  133. callback: {
  134. type: 'Client',
  135. method: 'goToLogin'
  136. }
  137. }));
  138. } else
  139. jobs.startJob(endpoint, msg.data, msg.callback, user);
  140. }
  141. }, 'router');
  142. }
  143. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement