diff --git a/gulpfile.js b/gulpfile.js index ad1990392..68e9c8903 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,8 +16,6 @@ var argv = require('yargs').argv, if (argv.help || argv.h) { console.log('Supported arguments for "gulp develop":'); - console.log(' --client-id '); - console.log(' --client-secret '); console.log(' --api-origin '); console.log(' --revision '); console.log(' --appstore-web-origin '); @@ -26,13 +24,8 @@ if (argv.help || argv.h) { process.exit(1); } -var oauth = { - clientId: argv.clientId || 'cid-webadmin', - clientSecret: argv.clientSecret || 'unused', - apiOrigin: argv.apiOrigin || '', -}; - -var revision = argv.revision || ''; +const apiOrigin = (argv.apiOrigin.indexOf('https://') === 0 ? argv.apiOrigin : ('https://' + argv.apiOrigin)) || ''; +const revision = argv.revision || ''; var appstore = { webOrigin: argv.appstoreWebOrigin || '', @@ -40,11 +33,7 @@ var appstore = { } console.log(); -console.log('Using OAuth credentials:'); -console.log(' ClientId: %s', oauth.clientId); -console.log(' ClientSecret: %s', oauth.clientSecret); -console.log(' Cloudron API: %s', oauth.apiOrigin || 'default'); -console.log(); +console.log('Cloudron API: %s', apiOrigin || 'default'); console.log('Building for revision: %s', revision); console.log(); console.log('Overriding appstore origin:'); @@ -95,7 +84,7 @@ gulp.task('js-index', function () { 'src/js/main.js', 'src/views/*.js' ]) - .pipe(ejs({ oauth: oauth, revision: revision, appstore: appstore }, {}, { ext: '.js' })) + .pipe(ejs({ apiOrigin: apiOrigin, revision: revision, appstore: appstore }, {}, { ext: '.js' })) .pipe(sourcemaps.init()) .pipe(concat('index.js', { newLine: ';' })) .pipe(sourcemaps.write()) @@ -104,7 +93,7 @@ gulp.task('js-index', function () { gulp.task('js-logs', function () { return gulp.src(['src/js/logs.js', 'src/js/client.js']) - .pipe(ejs({ oauth: oauth, appstore: appstore }, {}, { ext: '.js' })) + .pipe(ejs({ apiOrigin: apiOrigin, appstore: appstore }, {}, { ext: '.js' })) .pipe(sourcemaps.init()) .pipe(concat('logs.js', { newLine: ';' })) .pipe(sourcemaps.write()) @@ -113,7 +102,7 @@ gulp.task('js-logs', function () { gulp.task('js-terminal', function () { return gulp.src(['src/js/terminal.js', 'src/js/client.js']) - .pipe(ejs({ oauth: oauth, appstore: appstore }, {}, { ext: '.js' })) + .pipe(ejs({ apiOrigin: apiOrigin, appstore: appstore }, {}, { ext: '.js' })) .pipe(sourcemaps.init()) .pipe(concat('terminal.js', { newLine: ';' })) .pipe(sourcemaps.write()) @@ -122,7 +111,7 @@ gulp.task('js-terminal', function () { gulp.task('js-login', function () { return gulp.src(['src/js/login.js']) - .pipe(ejs({ oauth: oauth, appstore: appstore }, {}, { ext: '.js' })) + .pipe(ejs({ apiOrigin: apiOrigin, appstore: appstore }, {}, { ext: '.js' })) .pipe(sourcemaps.init()) .pipe(concat('login.js', { newLine: ';' })) .pipe(sourcemaps.write()) @@ -131,7 +120,7 @@ gulp.task('js-login', function () { gulp.task('js-setupaccount', function () { return gulp.src(['src/js/setupaccount.js']) - .pipe(ejs({ oauth: oauth, appstore: appstore }, {}, { ext: '.js' })) + .pipe(ejs({ apiOrigin: apiOrigin, appstore: appstore }, {}, { ext: '.js' })) .pipe(sourcemaps.init()) .pipe(concat('setupaccount.js', { newLine: ';' })) .pipe(sourcemaps.write()) @@ -140,7 +129,7 @@ gulp.task('js-setupaccount', function () { gulp.task('js-setup', function () { return gulp.src(['src/js/setup.js', 'src/js/client.js']) - .pipe(ejs({ oauth: oauth, appstore: appstore }, {}, { ext: '.js' })) + .pipe(ejs({ apiOrigin: apiOrigin, appstore: appstore }, {}, { ext: '.js' })) .pipe(sourcemaps.init()) .pipe(concat('setup.js', { newLine: ';' })) .pipe(sourcemaps.write()) @@ -149,7 +138,7 @@ gulp.task('js-setup', function () { gulp.task('js-setupdns', function () { return gulp.src(['src/js/setupdns.js', 'src/js/client.js']) - .pipe(ejs({ oauth: oauth, appstore: appstore }, {}, { ext: '.js' })) + .pipe(ejs({ apiOrigin: apiOrigin, appstore: appstore }, {}, { ext: '.js' })) .pipe(sourcemaps.init()) .pipe(concat('setupdns.js', { newLine: ';' })) .pipe(sourcemaps.write()) @@ -158,7 +147,7 @@ gulp.task('js-setupdns', function () { gulp.task('js-restore', function () { return gulp.src(['src/js/restore.js', 'src/js/client.js']) - .pipe(ejs({ oauth: oauth, appstore: appstore }, {}, { ext: '.js' })) + .pipe(ejs({ apiOrigin: apiOrigin, appstore: appstore }, {}, { ext: '.js' })) .pipe(sourcemaps.init()) .pipe(concat('restore.js', { newLine: ';' })) .pipe(sourcemaps.write()) @@ -180,7 +169,7 @@ gulp.task('html-templates', function () { }); gulp.task('html-raw', function () { - return gulp.src('src/*.html').pipe(ejs({ apiOrigin: oauth.apiOrigin, revision: revision }, {}, { ext: '.html' })).pipe(gulp.dest('dist')); + return gulp.src('src/*.html').pipe(ejs({ apiOrigin: apiOrigin, revision: revision }, {}, { ext: '.html' })).pipe(gulp.dest('dist')); }); gulp.task('html', gulp.series(['html-views', 'html-templates', 'html-raw'])); diff --git a/src/js/client.js b/src/js/client.js index 66e2ad4c5..44dcbbfb3 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -221,10 +221,8 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout this._installedApps = []; this._installedAppsById = {}; this._appTags = []; - this._clientId = '<%= oauth.clientId %>'; - this._clientSecret = '<%= oauth.clientSecret %>'; // window.location fallback for websocket connections which do not have relative uris - this.apiOrigin = '<%= oauth.apiOrigin %>' || window.location.origin; + this.apiOrigin = '<%= apiOrigin %>' || window.location.origin; this.avatar = ''; this._appstoreAppCache = []; diff --git a/src/js/login.js b/src/js/login.js index 80cac2cda..d536d92f0 100644 --- a/src/js/login.js +++ b/src/js/login.js @@ -19,7 +19,7 @@ app.controller('LoginController', ['$scope', '$http', function ($scope, $http) { $scope.passwordResetIdentifier = ''; $scope.newPassword = ''; $scope.newPasswordRepeat = ''; - var API_ORIGIN = '<%= oauth.apiOrigin %>' || window.location.origin; + var API_ORIGIN = '<%= apiOrigin %>' || window.location.origin; $scope.onLogin = function () { $scope.busy = true; diff --git a/src/js/setupaccount.js b/src/js/setupaccount.js index b3d7954e5..958a00016 100644 --- a/src/js/setupaccount.js +++ b/src/js/setupaccount.js @@ -9,7 +9,7 @@ app.controller('SetupAccountController', ['$scope', '$http', function ($scope, $ // Stupid angular location provider either wants html5 location mode or not, do the query parsing on my own var search = decodeURIComponent(window.location.search).slice(1).split('&').map(function (item) { return item.indexOf('=') === -1 ? [item, true] : [item.slice(0, item.indexOf('=')), item.slice(item.indexOf('=')+1)]; }).reduce(function (o, k) { o[k[0]] = k[1]; return o; }, {}); - var API_ORIGIN = '<%= oauth.apiOrigin %>' || window.location.origin; + var API_ORIGIN = '<%= apiOrigin %>' || window.location.origin; $scope.busy = false; $scope.error = null;