|
|
|
|
@ -6,9 +6,12 @@ import { getWorkspaceAccessToken } from './functions/getWorkspaceAccessToken'; |
|
|
|
|
import { getWorkspaceAccessTokenWithScope } from './functions/getWorkspaceAccessTokenWithScope'; |
|
|
|
|
import { getWorkspaceLicense } from './functions/getWorkspaceLicense'; |
|
|
|
|
import { getUserCloudAccessToken } from './functions/getUserCloudAccessToken'; |
|
|
|
|
import { retrieveRegistrationStatus } from './functions/retrieveRegistrationStatus'; |
|
|
|
|
import { getWorkspaceKey } from './functions/getWorkspaceKey'; |
|
|
|
|
import { syncWorkspace } from './functions/syncWorkspace'; |
|
|
|
|
import { connectWorkspace } from './functions/connectWorkspace'; |
|
|
|
|
import { settings } from '../../settings/server'; |
|
|
|
|
import { SystemLogger } from '../../../server/lib/logger/system'; |
|
|
|
|
|
|
|
|
|
const licenseCronName = 'Cloud Workspace Sync'; |
|
|
|
|
|
|
|
|
|
@ -34,6 +37,22 @@ Meteor.startup(function() { |
|
|
|
|
job: syncWorkspace, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const { workspaceRegistered } = retrieveRegistrationStatus(); |
|
|
|
|
|
|
|
|
|
if (process.env.REG_TOKEN && process.env.REG_TOKEN !== '' && !workspaceRegistered) { |
|
|
|
|
try { |
|
|
|
|
SystemLogger.info('REG_TOKEN Provided. Attempting to register'); |
|
|
|
|
|
|
|
|
|
if (!connectWorkspace(process.env.REG_TOKEN)) { |
|
|
|
|
throw new Error('Couldn\'t register with token. Please make sure token is valid or hasn\'t already been used'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('Successfully registered with token provided by REG_TOKEN!'); |
|
|
|
|
} catch (e) { |
|
|
|
|
SystemLogger.error('An error occured registering with token.', e.message); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
export { getWorkspaceAccessToken, getWorkspaceAccessTokenWithScope, getWorkspaceLicense, getWorkspaceKey, getUserCloudAccessToken }; |
|
|
|
|
|