Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert rocketchat-oauth2-server-config to main module structure #12773

Merged
merged 2 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Mongo } from 'meteor/mongo';

export const ChatOAuthApps = new Mongo.Collection('rocketchat_oauth_apps');
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FlowRouter } from 'meteor/kadira:flow-router' ;
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { t } from 'meteor/rocketchat:ui';

FlowRouter.route('/admin/oauth-apps', {
name: 'admin-oauth-apps',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.AdminBox.addOption({
href: 'admin-oauth-apps',
i18nLabel: 'OAuth Apps',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* globals ChatOAuthApps */

import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat, handleError } from 'meteor/rocketchat:lib';
import { t, modal } from 'meteor/rocketchat:ui';
import { ChatOAuthApps } from '../collection';
import toastr from 'toastr';

Template.oauthApp.onCreated(function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals ChatOAuthApps */
import { Template } from 'meteor/templating';
import { RocketChat } from 'meteor/rocketchat:lib';
import { ChatOAuthApps } from '../collection';
import moment from 'moment';

Template.oauthApps.onCreated(function() {
Expand Down
9 changes: 9 additions & 0 deletions packages/rocketchat-oauth2-server-config/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import './oauth/stylesheets/oauth2.css';
import './oauth/oauth2-client.html';
import './oauth/oauth2-client';
import './admin/startup';
import './admin/route';
import './admin/views/oauthApp.html';
import './admin/views/oauthApp';
import './admin/views/oauthApps.html';
import './admin/views/oauthApps';
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// @ChatOAuthApps = new Mongo.Collection 'rocketchat_oauth_apps'
/* globals ChatOAuthApps */
import { Meteor } from 'meteor/meteor';
import { FlowRouter } from 'meteor/kadira:flow-router' ;
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { Template } from 'meteor/templating';
import { ChatOAuthApps } from '../admin/collection';

FlowRouter.route('/oauth/authorize', {
action(params, queryParams) {
Expand Down
57 changes: 14 additions & 43 deletions packages/rocketchat-oauth2-server-config/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,18 @@ Package.describe({
});

Package.onUse(function(api) {
api.use('webapp');
api.use('mongo');
api.use('ecmascript');
api.use('rocketchat:lib');
api.use('rocketchat:api');
api.use('rocketchat:theme');
api.use('rocketchat:oauth2-server');

api.use('templating', 'client');
api.use('kadira:flow-router', 'client');
api.use('kadira:blaze-layout', 'client');

// // General //
// Server
api.addFiles('server/models/OAuthApps.js', 'server');

// // OAuth //
// Server
api.addFiles('oauth/server/oauth2-server.js', 'server');
api.addFiles('oauth/server/default-services.js', 'server');

api.addFiles('oauth/client/stylesheets/oauth2.css', 'client');

// Client
api.addFiles('oauth/client/oauth2-client.html', 'client');
api.addFiles('oauth/client/oauth2-client.js', 'client');


// // Admin //
// Client
api.addFiles('admin/client/startup.js', 'client');
api.addFiles('admin/client/collection.js', 'client');
api.addFiles('admin/client/route.js', 'client');
api.addFiles('admin/client/views/oauthApp.html', 'client');
api.addFiles('admin/client/views/oauthApp.js', 'client');
api.addFiles('admin/client/views/oauthApps.html', 'client');
api.addFiles('admin/client/views/oauthApps.js', 'client');

// Server
api.addFiles('admin/server/publications/oauthApps.js', 'server');
api.addFiles('admin/server/methods/addOAuthApp.js', 'server');
api.addFiles('admin/server/methods/updateOAuthApp.js', 'server');
api.addFiles('admin/server/methods/deleteOAuthApp.js', 'server');
api.use([
'ecmascript',
'webapp',
'mongo',
'rocketchat:lib',
'rocketchat:api',
'rocketchat:theme',
'rocketchat:oauth2-server',
'templating',
'kadira:flow-router',
'kadira:blaze-layout',
]);
api.mainModule('client/index.js', 'client');
api.mainModule('server/index.js', 'server');
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { RocketChat } from 'meteor/rocketchat:lib';
import _ from 'underscore';

Meteor.methods({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
deleteOAuthApp(applicationId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import _ from 'underscore';

Meteor.methods({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.publish('oauthApps', function() {
if (!this.userId) {
Expand Down
7 changes: 7 additions & 0 deletions packages/rocketchat-oauth2-server-config/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import './models/OAuthApps';
import './oauth/oauth2-server';
import './oauth/default-services';
import './admin/publications/oauthApps';
import './admin/methods/addOAuthApp';
import './admin/methods/updateOAuthApp';
import './admin/methods/deleteOAuthApp';
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.models.OAuthApps = new class extends RocketChat.models._Base {
constructor() {
super('oauth_apps');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RocketChat } from 'meteor/rocketchat:lib';

if (!RocketChat.models.OAuthApps.findOne('zapier')) {
RocketChat.models.OAuthApps.insert({
_id: 'zapier',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global OAuth2Server */
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import { RocketChat } from 'meteor/rocketchat:lib';
import { OAuth2Server } from 'meteor/rocketchat:oauth2-server';

const oauth2server = new OAuth2Server({
accessTokensCollectionName: 'rocketchat_oauth_access_tokens',
Expand Down