The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/apps/meteor/app/cloud/server/methods.ts

238 lines
6.7 KiB

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import type { ServerMethods } from '@rocket.chat/ui-contexts';
import { retrieveRegistrationStatus } from './functions/retrieveRegistrationStatus';
import { connectWorkspace } from './functions/connectWorkspace';
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
import { reconnectWorkspace } from './functions/reconnectWorkspace';
import { getOAuthAuthorizationUrl } from './functions/getOAuthAuthorizationUrl';
import { finishOAuthAuthorization } from './functions/finishOAuthAuthorization';
import { startRegisterWorkspace } from './functions/startRegisterWorkspace';
import { disconnectWorkspace } from './functions/disconnectWorkspace';
import { syncWorkspace } from './functions/syncWorkspace';
import { checkUserHasCloudLogin } from './functions/checkUserHasCloudLogin';
import { userLogout } from './functions/userLogout';
import { hasPermissionAsync } from '../../authorization/server/functions/hasPermission';
import { buildWorkspaceRegistrationData } from './functions/buildRegistrationData';
declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
'cloud:checkRegisterStatus': () => {
connectToCloud: boolean;
workspaceRegistered: boolean;
workspaceId: string;
uniqueId: string;
token: string;
email: string;
};
'cloud:getWorkspaceRegisterData': () => string;
'cloud:registerWorkspace': () => boolean;
'cloud:syncWorkspace': () => boolean;
'cloud:connectWorkspace': (token: string) => boolean | Error;
'cloud:reconnectWorkspace': () => boolean;
'cloud:disconnectWorkspace': () => boolean;
'cloud:getOAuthAuthorizationUrl': () => string;
'cloud:finishOAuthAuthorization': (code: string, state: string) => boolean;
'cloud:checkUserLoggedIn': () => boolean;
'cloud:logout': () => Promise<boolean | string>;
}
}
Meteor.methods<ServerMethods>({
async 'cloud:checkRegisterStatus'() {
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'cloud:checkRegisterStatus',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
method: 'cloud:checkRegisterStatus',
});
}
return retrieveRegistrationStatus();
},
async 'cloud:getWorkspaceRegisterData'() {
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'cloud:getWorkspaceRegisterData',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
method: 'cloud:getWorkspaceRegisterData',
});
}
return Buffer.from(JSON.stringify(await buildWorkspaceRegistrationData(undefined))).toString('base64');
},
async 'cloud:registerWorkspace'() {
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:registerWorkspace',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:registerWorkspace',
});
}
return startRegisterWorkspace();
},
async 'cloud:syncWorkspace'() {
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'cloud:syncWorkspace',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
method: 'cloud:syncWorkspace',
});
}
return syncWorkspace();
},
async 'cloud:connectWorkspace'(token) {
check(token, String);
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:connectWorkspace',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:connectWorkspace',
});
}
if (!token) {
throw new Meteor.Error('error-invalid-payload', 'Token is required.', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:connectWorkspace',
});
}
return connectWorkspace(token);
},
async 'cloud:disconnectWorkspace'() {
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'cloud:connectServer',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
method: 'cloud:connectServer',
});
}
return disconnectWorkspace();
},
async 'cloud:reconnectWorkspace'() {
const uid = Meteor.userId();
if (!uid) {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'cloud:reconnectWorkspace',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
method: 'cloud:reconnectWorkspace',
});
}
return reconnectWorkspace();
},
// Currently unused but will link local account to Rocket.Chat Cloud account.
async 'cloud:getOAuthAuthorizationUrl'() {
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:getOAuthAuthorizationUrl',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:getOAuthAuthorizationUrl',
});
}
return getOAuthAuthorizationUrl();
},
async 'cloud:finishOAuthAuthorization'(code, state) {
check(code, String);
check(state, String);
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'cloud:finishOAuthAuthorization',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:finishOAuthAuthorization',
});
}
return finishOAuthAuthorization(code, state);
},
async 'cloud:checkUserLoggedIn'() {
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:checkUserLoggedIn',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:checkUserLoggedIn',
});
}
return checkUserHasCloudLogin(uid);
},
async 'cloud:logout'() {
const uid = Meteor.userId();
if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:logout',
});
}
if (!(await hasPermissionAsync(uid, 'manage-cloud'))) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', {
[IMPROVE] Registration Experience (#27820) * chore: add register button to kebab menu * chore: change name section to registration * chore: use new register section * chore: add registered workspace modal * chore: Add workspace registration modal * chore: register workspace setup modal * chore: add modal to register workspace with token * chore: adding translations to workspace registration * chore: open registered modal when user clicks manage * chore: separate register workspace setup modals * feat: Add deregister flow * feat: register workspace connected with backend * feat: register with token connected with backend service * improve: Use workspace token when interacting with Marketplace (#27875) * add: use workspace token when interacting with Marketplace * fix: formatting --------- Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * improve: Remove Cloud Login restrictions from Marketplace (#27896) * feat: remove login button * feat: remove login button * fix: add developmentModeButton --------- Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> * Sync disconnect wishes * correct boolean to pass inverse If registerServer is true needs to pass false as they didn't chose not to be * added reconnect method * added reconnect method * add back the disconnect since the unregister code was reverted * chore: move register setup to another modal * chore: add connect workspace functionality * chore: finishing workspace registration * fix broken import * fix: add missing translations * fix: tests dependencies * fix: small lint issue * deregister / unregister -> disconnect in i18n * remove un-necessary sync * finish #27896 remove login requirement from marketplace * remove unused imports * fix: administration model list tests * deregister -> disconnect * fix: duplied translation * fix: iframe modal url token object error * fix: translations error, CS-353, CS-340 --------- Co-authored-by: Pedro Berleze Rorato <41977327+PedroRorato@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com> Co-authored-by: David Alen <davidalen.dev@gmail.com> Co-authored-by: Thassio Victor <tvmcarvalho@gmail.com> Co-authored-by: Aaron Ogle <aaron@geekgonecrazy.com> Co-authored-by: PedroRorato <pedroberorato@gmail.com>
3 years ago
method: 'cloud:logout',
});
}
return userLogout(uid);
},
});