From 3b31125a62b4095016a574dd8dfade8da60a3a4b Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Thu, 16 Aug 2018 14:11:43 +0100 Subject: [PATCH 01/11] Add message about deleting account affecting v2 Only show on SL and if the user has linked accounts --- services/web/app/views/user/settings.pug | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/web/app/views/user/settings.pug b/services/web/app/views/user/settings.pug index e4da83c1db..d231047d8d 100644 --- a/services/web/app/views/user/settings.pug +++ b/services/web/app/views/user/settings.pug @@ -167,7 +167,12 @@ block content ) i.fa.fa-check | #{translate("unsubscribed")} - + + if !settings.overleaf && user.overleaf + p + | Please note: If you have linked your account with Overleaf + | v2, then deleting your ShareLaTeX account will also delete + | account and all of it's associated projects and data. p #{translate("need_to_leave")} a(href, ng-click="deleteAccount()") #{translate("delete_your_account")} From dfc25a093b3959e3494908b49675b3bce6aeccfc Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 16 Aug 2018 16:28:02 +0100 Subject: [PATCH 02/11] Fix review icon for Overleaf. --- .../web/public/img/review-icon-sprite-ol.png | Bin 0 -> 765 bytes .../public/img/review-icon-sprite-ol@2x.png | Bin 0 -> 1082 bytes .../stylesheets/app/editor/review-panel.less | 17 ++++++++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 services/web/public/img/review-icon-sprite-ol.png create mode 100644 services/web/public/img/review-icon-sprite-ol@2x.png diff --git a/services/web/public/img/review-icon-sprite-ol.png b/services/web/public/img/review-icon-sprite-ol.png new file mode 100644 index 0000000000000000000000000000000000000000..1e5c7192e4d649f6e1cff67cbc31dfffaca2c6ea GIT binary patch literal 765 zcmVeV^tcYf!5pY!|oebOAq2~0(q7MP-v3jE(nx{o%~QG!Lt zLkPooi&yBy`+pg@5IeCA%M-M-pdGl3n;7>KI4#C<%EDpPW47wL@mybMfijVgVw56R z?H=GLI+I4Wz%Dts>sstRmEw(6E(Jqi=`l>67d#3(8!@Re1r?yXQ=qps~eYvVl|oz)9b zgf6uEToKtg?Yf??<2Q`q6Fw)~Kyq~aVDrsqV4L|%ab4FdJogJwgR9t&V60hPf^qa} zk|pcn#TY>w!s^;q-D}XhtPCQebDOxC-Z4%`rrFbyzYgu1B2ME zy3Odo0>Q vFWH%0}WF zc!BXTe@Q0s)|&?(o1e)f-+XUo-n`kREX#t!WJiKSW}dJo>} z!7U{BruaKYEF@u0DnjsMX8GJ6HozD$ZG!Mp$yk~z*a7qeHLDs|d;}QOsy-)N0Bt~= z)o(GrD{ze>3ikm!7UezyKH>2@?nT1A3;4SRShuKa3$WX?!XaRyQDY8x2-pN1E7002 z_{=t7rm25|-{3@H8?ve5LtX){1C||q46p08;$5jL(q+hg#*YhX!ZmzHEu@Q*ec(`0 z9hUK3DY|=(4}kM^5S}Q=1`T6PaxHRAxYsaQMj*T2M&$R;xg?x6NOnikPidKM z+t|F6=d}!kzci?>NZ7P;8ZA-+pikWPatT-E!o+|CF|_W}h7o$DhAAkMjJl#Fno&AI zWSS7PU1VCKmAMWfY5h#n(5Z&7t+j2Zr7=0b=+Koz;;vhm^$19xwH>MXvT*~@73#?? zv32RTq_s93sXHs6BGcSU6%iR-Vn#L!&m}4k3e1fvqp6^-!LxJ&*M>yV{5pN7)hNA1 z&d&m#RwNt~a$`wD(*Q(fV@D2sR@0EEy?N zA~4i>i7uxlo7;FGvJH4CDSr|hhAMThghzbC_wVC3tP7Ff)G#n!#p7RqD}cAQIW4Bi zWj&FUzmy$3dsH-Q$qx8SqqIIhI6m)_Li^ zBnq1wo-wU+DPl$NFeDjFT^*?;iu((;TP?fTx{08|DZmN9cS(7gzwQbiBa3+ls7R0W z$GN1BhKhb15$_qf*mTB2!k(}v>wrg*!~g&Q07*qoM6N<$g7n$+ A0ssI2 literal 0 HcmV?d00001 diff --git a/services/web/public/stylesheets/app/editor/review-panel.less b/services/web/public/stylesheets/app/editor/review-panel.less index 800a25618f..a7e7d3fdbd 100644 --- a/services/web/public/stylesheets/app/editor/review-panel.less +++ b/services/web/public/stylesheets/app/editor/review-panel.less @@ -922,7 +922,7 @@ } } -.review-icon { +.review-icon when (@is-overleaf = false) { display: inline-block; background: url('/img/review-icon-sprite.png') top/30px no-repeat; width: 30px; @@ -945,10 +945,17 @@ } } -.review-icon when (@is-overleaf) { - background-position-y: -60px; - .toolbar .btn-full-height:hover & { - background-position-y: -60px; +.review-icon when (@is-overleaf = true) { + display: inline-block; + background: url('/img/review-icon-sprite-ol.png') top/30px no-repeat; + width: 30px; + + &::before { + content: '\00a0'; // Non-breakable space. A non-breakable character here makes this icon work like font-awesome. + } + + @media (min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { + background-image: url('/img/review-icon-sprite-ol@2x.png'); } } From 9bc3fa2df0538a143f320d176a8af354317fe1d0 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Fri, 17 Aug 2018 12:04:05 +0100 Subject: [PATCH 03/11] Pass req to preDoPassportLogin module hook --- .../Features/Authentication/AuthenticationController.coffee | 2 +- .../Authentication/AuthenticationControllerTests.coffee | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee b/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee index 951506891f..d7e9ed4bc6 100644 --- a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee +++ b/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee @@ -84,7 +84,7 @@ module.exports = AuthenticationController = doPassportLogin: (req, username, password, done) -> email = username.toLowerCase() Modules = require "../../infrastructure/Modules" - Modules.hooks.fire 'preDoPassportLogin', email, (err, infoList) -> + Modules.hooks.fire 'preDoPassportLogin', req, email, (err, infoList) -> return next(err) if err? info = infoList.find((i) => i?) if info? diff --git a/services/web/test/unit/coffee/Authentication/AuthenticationControllerTests.coffee b/services/web/test/unit/coffee/Authentication/AuthenticationControllerTests.coffee index ae8fedc9c8..24af9971d2 100644 --- a/services/web/test/unit/coffee/Authentication/AuthenticationControllerTests.coffee +++ b/services/web/test/unit/coffee/Authentication/AuthenticationControllerTests.coffee @@ -214,7 +214,7 @@ describe "AuthenticationController", -> beforeEach -> @AuthenticationController._recordFailedLogin = sinon.stub() @AuthenticationController._recordSuccessfulLogin = sinon.stub() - @Modules.hooks.fire = sinon.stub().callsArgWith(2, null, []) + @Modules.hooks.fire = sinon.stub().callsArgWith(3, null, []) # @AuthenticationController.establishUserSession = sinon.stub().callsArg(2) @req.body = email: @email @@ -225,7 +225,7 @@ describe "AuthenticationController", -> describe "when the preDoPassportLogin hooks produce an info object", -> beforeEach -> - @Modules.hooks.fire = sinon.stub().callsArgWith(2, null, [null, {redir: '/somewhere'}, null]) + @Modules.hooks.fire = sinon.stub().callsArgWith(3, null, [null, {redir: '/somewhere'}, null]) it "should stop early and call done with this info object", (done) -> @AuthenticationController.doPassportLogin(@req, @req.body.email, @req.body.password, @cb) From 356e31caecd1173f1eba502d12f9007a0ef525d9 Mon Sep 17 00:00:00 2001 From: Jessica Lawshe Date: Wed, 15 Aug 2018 13:32:26 -0500 Subject: [PATCH 04/11] Set variant when sixpack request successful --- services/web/public/coffee/main/plans.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/main/plans.coffee b/services/web/public/coffee/main/plans.coffee index 1637d79374..258f84b62c 100644 --- a/services/web/public/coffee/main/plans.coffee +++ b/services/web/public/coffee/main/plans.coffee @@ -152,8 +152,9 @@ define [ if $scope.shouldABTestPlans sixpack.participate 'plans-details', ['default', 'more-details'], (chosenVariation, rawResponse)-> - $scope.plansVariant = chosenVariation - event_tracking.send 'subscription-funnel', 'plans-page-loaded', chosenVariation + if rawResponse?.status != 'failed' + $scope.plansVariant = chosenVariation + event_tracking.send 'subscription-funnel', 'plans-page-loaded', chosenVariation $scope.showPlans = true From 5b5ece37a5fbb41be076373465f05d0f1a652c63 Mon Sep 17 00:00:00 2001 From: Jessica Lawshe Date: Wed, 15 Aug 2018 14:11:58 -0500 Subject: [PATCH 05/11] Handle sixpack timeouts and include variant in metabase segmentation Render default when sixpack timesout Only convert when variant exists Use Angular cookies module to add variant cookie, which is used on the new subscription page. --- services/web/app/views/subscriptions/plans.pug | 2 +- .../public/coffee/main/new-subscription.coffee | 17 ++++++++--------- services/web/public/coffee/main/plans.coffee | 11 ++++++++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/services/web/app/views/subscriptions/plans.pug b/services/web/app/views/subscriptions/plans.pug index 0a37b90dd8..51efcd5125 100644 --- a/services/web/app/views/subscriptions/plans.pug +++ b/services/web/app/views/subscriptions/plans.pug @@ -14,5 +14,5 @@ block content .content.plans(ng-controller="PlansController") .container(class="more-details" ng-cloak ng-if="plansVariant === 'more-details'") include _plans_page_details_more - .container(ng-cloak ng-if="plansVariant === 'default' || !shouldABTestPlans") + .container(ng-cloak ng-if="plansVariant === 'default' || !shouldABTestPlans || timeout") include _plans_page_details_less diff --git a/services/web/public/coffee/main/new-subscription.coffee b/services/web/public/coffee/main/new-subscription.coffee index 7851171524..e8294a5885 100644 --- a/services/web/public/coffee/main/new-subscription.coffee +++ b/services/web/public/coffee/main/new-subscription.coffee @@ -4,20 +4,21 @@ define [ "libs/recurly-4.8.5" ], (App)-> - App.controller "NewSubscriptionController", ($scope, MultiCurrencyPricing, abTestManager, $http, sixpack, event_tracking, ccUtils)-> + App.controller "NewSubscriptionController", ($scope, MultiCurrencyPricing, abTestManager, $http, sixpack, event_tracking, ccUtils, ipCookie)-> throw new Error("Recurly API Library Missing.") if typeof recurly is "undefined" $scope.currencyCode = MultiCurrencyPricing.currencyCode $scope.plans = MultiCurrencyPricing.plans $scope.planCode = window.plan_code + $scope.plansVariant = ipCookie('plansVariant') $scope.switchToStudent = ()-> currentPlanCode = window.plan_code planCode = currentPlanCode.replace('collaborator', 'student') - event_tracking.sendMB 'subscription-form-switch-to-student', { plan: window.plan_code } + event_tracking.sendMB 'subscription-form-switch-to-student', { plan: window.plan_code, variant: $scope.plansVariant } window.location = "/user/subscription/new?planCode=#{planCode}¤cy=#{$scope.currencyCode}&cc=#{$scope.data.coupon}" - event_tracking.sendMB "subscription-form", { plan : window.plan_code } + event_tracking.sendMB "subscription-form", { plan : window.plan_code, variant: $scope.plansVariant } $scope.paymentMethod = value: "credit_card" @@ -143,13 +144,14 @@ define [ currencyCode : postData.subscriptionDetails.currencyCode, plan_code : postData.subscriptionDetails.plan_code, coupon_code : postData.subscriptionDetails.coupon_code, - isPaypal : postData.subscriptionDetails.isPaypal + isPaypal : postData.subscriptionDetails.isPaypal, + variant : $scope.plansVariant } $http.post("/user/subscription/create", postData) .then ()-> - event_tracking.sendMB "subscription-submission-success" + event_tracking.sendMB "subscription-submission-success", { variant: $scope.plansVariant } window.location.href = "/user/subscription/thank-you" .catch ()-> $scope.processing = false @@ -234,7 +236,4 @@ define [ {code:'VU',name:'Vanuatu'},{code:'VA',name:'Vatican City'},{code:'VE',name:'Venezuela'},{code:'VN',name:'Vietnam'}, {code:'WK',name:'Wake Island'},{code:'WF',name:'Wallis and Futuna'},{code:'EH',name:'Western Sahara'},{code:'YE',name:'Yemen'}, {code:'ZM',name:'Zambia'},{code:'AX',name:'Åland Islandscode:'} - ] - - sixpack.participate 'plans', ['default', 'more-details'], (chosenVariation, rawResponse)-> - $scope.plansVariant = chosenVariation \ No newline at end of file + ] \ No newline at end of file diff --git a/services/web/public/coffee/main/plans.coffee b/services/web/public/coffee/main/plans.coffee index 258f84b62c..f13dff689f 100644 --- a/services/web/public/coffee/main/plans.coffee +++ b/services/web/public/coffee/main/plans.coffee @@ -145,7 +145,7 @@ define [ } - App.controller "PlansController", ($scope, $modal, event_tracking, abTestManager, MultiCurrencyPricing, $http, sixpack, $filter) -> + App.controller "PlansController", ($scope, $modal, event_tracking, abTestManager, MultiCurrencyPricing, $http, sixpack, $filter, ipCookie) -> $scope.showPlans = false $scope.shouldABTestPlans = window.shouldABTestPlans @@ -154,7 +154,12 @@ define [ sixpack.participate 'plans-details', ['default', 'more-details'], (chosenVariation, rawResponse)-> if rawResponse?.status != 'failed' $scope.plansVariant = chosenVariation + expiration = new Date(); + expiration.setDate(expiration.getDate() + 5); + ipCookie('plansVariant', chosenVariation, {expires: expiration}) event_tracking.send 'subscription-funnel', 'plans-page-loaded', chosenVariation + else + $scope.timeout = true $scope.showPlans = true @@ -185,9 +190,9 @@ define [ if $scope.ui.view == "annual" plan = "#{plan}_annual" plan = eventLabel(plan, location) - event_tracking.sendMB 'plans-page-start-trial', {plan} + event_tracking.sendMB 'plans-page-start-trial', {plan, variant: $scope.plansVariant} event_tracking.send 'subscription-funnel', 'sign_up_now_button', plan - if $scope.shouldABTestPlans + if $scope.plansVariant sixpack.convert 'plans-details' $scope.switchToMonthly = (e, location) -> From f5513f36ca2222fb4f360cbbea420949c294e878 Mon Sep 17 00:00:00 2001 From: Tim Alby Date: Fri, 17 Aug 2018 15:08:59 +0200 Subject: [PATCH 06/11] add param to skip affiliation creation on user create --- .../app/coffee/Features/User/UserCreator.coffee | 16 ++++++++++------ .../unit/coffee/User/UserCreatorTests.coffee | 8 ++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/services/web/app/coffee/Features/User/UserCreator.coffee b/services/web/app/coffee/Features/User/UserCreator.coffee index 2dfa7f5ac0..17248b38ae 100644 --- a/services/web/app/coffee/Features/User/UserCreator.coffee +++ b/services/web/app/coffee/Features/User/UserCreator.coffee @@ -6,15 +6,18 @@ metrics = require('metrics-sharelatex') module.exports = UserCreator = - createNewUser: (opts, callback)-> - logger.log opts:opts, "creating new user" + createNewUser: (attributes, options, callback = (error, user) ->)-> + if arguments.length == 2 + callback = options + options = {} + logger.log user: attributes, "creating new user" user = new User() - username = opts.email.match(/^[^@]*/) - if !opts.first_name? or opts.first_name == "" - opts.first_name = username[0] + username = attributes.email.match(/^[^@]*/) + if !attributes.first_name? or attributes.first_name == "" + attributes.first_name = username[0] - for key, value of opts + for key, value of attributes user[key] = value user.ace.syntaxValidation = true @@ -27,6 +30,7 @@ module.exports = UserCreator = user.save (err)-> callback(err, user) + return if options?.skip_affiliation # call addaffiliation after the main callback so it runs in the # background. There is no guaranty this will run so we must no rely on it addAffiliation user._id, user.email, (error) -> diff --git a/services/web/test/unit/coffee/User/UserCreatorTests.coffee b/services/web/test/unit/coffee/User/UserCreatorTests.coffee index f9d88e4cf8..5f3bf60e6a 100644 --- a/services/web/test/unit/coffee/User/UserCreatorTests.coffee +++ b/services/web/test/unit/coffee/User/UserCreatorTests.coffee @@ -88,3 +88,11 @@ describe "UserCreator", -> process.nextTick () => sinon.assert.calledWith(@addAffiliation, user._id, user.email) done() + + it "should not add affiliation if skipping", (done)-> + attributes = email: @email + options = skip_affiliation: true + @UserCreator.createNewUser attributes, options, (err, user) => + process.nextTick () => + sinon.assert.notCalled(@addAffiliation) + done() From 8d6505b518f74b8797eb673293a3e5b24128f77a Mon Sep 17 00:00:00 2001 From: Tim Alby Date: Fri, 17 Aug 2018 15:13:24 +0200 Subject: [PATCH 07/11] log institutions API errors --- .../web/app/coffee/Features/Institutions/InstitutionsAPI.coffee | 2 ++ services/web/test/unit/coffee/User/UserCreatorTests.coffee | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/Institutions/InstitutionsAPI.coffee b/services/web/app/coffee/Features/Institutions/InstitutionsAPI.coffee index 8ce39d68e3..c62a8a01bc 100644 --- a/services/web/app/coffee/Features/Institutions/InstitutionsAPI.coffee +++ b/services/web/app/coffee/Features/Institutions/InstitutionsAPI.coffee @@ -80,6 +80,8 @@ makeAffiliationRequest = (requestOptions, callback = (error) ->) -> errorMessage = "#{response.statusCode}: #{body.errors}" else errorMessage = "#{requestOptions.defaultErrorMessage}: #{response.statusCode}" + + logger.err path: requestOptions.path, body: requestOptions.body, errorMessage return callback(new Error(errorMessage)) callback(null, body) diff --git a/services/web/test/unit/coffee/User/UserCreatorTests.coffee b/services/web/test/unit/coffee/User/UserCreatorTests.coffee index 5f3bf60e6a..d9118e450f 100644 --- a/services/web/test/unit/coffee/User/UserCreatorTests.coffee +++ b/services/web/test/unit/coffee/User/UserCreatorTests.coffee @@ -20,7 +20,7 @@ describe "UserCreator", -> @addAffiliation = sinon.stub().yields() @UserCreator = SandboxedModule.require modulePath, requires: "../../models/User": User:@UserModel - "logger-sharelatex":{log:->} + "logger-sharelatex":{ log: sinon.stub(), err: sinon.stub() } 'metrics-sharelatex': {timeAsyncMethod: ()->} "../Institutions/InstitutionsAPI": addAffiliation: @addAffiliation From 47c51257bbbaff6a4f57f3dc9ef3b17f83d37f81 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 20 Aug 2018 11:51:12 +0100 Subject: [PATCH 08/11] Explicitly set the user default email for the delete account modal controller. --- .../coffee/main/account-settings.coffee | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/services/web/public/coffee/main/account-settings.coffee b/services/web/public/coffee/main/account-settings.coffee index 82d323110e..b12b8f3dde 100644 --- a/services/web/public/coffee/main/account-settings.coffee +++ b/services/web/public/coffee/main/account-settings.coffee @@ -1,7 +1,7 @@ define [ "base" ], (App) -> - App.controller "AccountSettingsController", ["$scope", "$http", "$modal", "event_tracking", ($scope, $http, $modal, event_tracking) -> + App.controller "AccountSettingsController", ["$scope", "$http", "$modal", "event_tracking", "UserAffiliationsDataService", ($scope, $http, $modal, event_tracking, UserAffiliationsDataService) -> $scope.subscribed = true $scope.unsubscribe = () -> @@ -21,8 +21,15 @@ define [ $scope.deleteAccount = () -> modalInstance = $modal.open( templateUrl: "deleteAccountModalTemplate" - controller: "DeleteAccountModalController", - scope: $scope + controller: "DeleteAccountModalController" + resolve: + userDefaultEmail: () -> + UserAffiliationsDataService + .getUserEmails() + .then (userEmails) -> + defaultEmailDetails = _.find userEmails, (userEmail) -> userEmail.default + return defaultEmailDetails?.email or null + .catch () -> null ) $scope.upgradeIntegration = (service) -> @@ -30,8 +37,8 @@ define [ ] App.controller "DeleteAccountModalController", [ - "$scope", "$modalInstance", "$timeout", "$http", - ($scope, $modalInstance, $timeout, $http) -> + "$scope", "$modalInstance", "$timeout", "$http", "userDefaultEmail", + ($scope, $modalInstance, $timeout, $http, userDefaultEmail) -> $scope.state = isValid : false deleteText: "" @@ -46,7 +53,7 @@ define [ , 700 $scope.checkValidation = -> - $scope.state.isValid = $scope.state.deleteText == $scope.email and $scope.state.password.length > 0 + $scope.state.isValid = userDefaultEmail? and $scope.state.deleteText == userDefaultEmail and $scope.state.password.length > 0 $scope.delete = () -> $scope.state.inflight = true From 042c959d3acb5e701d03a2ff1b2ceff5306944cc Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 20 Aug 2018 12:15:15 +0100 Subject: [PATCH 09/11] Move default email checking logic into the data service. --- services/web/public/coffee/main/account-settings.coffee | 5 ++--- .../factories/UserAffiliationsDataService.coffee | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/services/web/public/coffee/main/account-settings.coffee b/services/web/public/coffee/main/account-settings.coffee index b12b8f3dde..cac35394a1 100644 --- a/services/web/public/coffee/main/account-settings.coffee +++ b/services/web/public/coffee/main/account-settings.coffee @@ -25,9 +25,8 @@ define [ resolve: userDefaultEmail: () -> UserAffiliationsDataService - .getUserEmails() - .then (userEmails) -> - defaultEmailDetails = _.find userEmails, (userEmail) -> userEmail.default + .getUserDefaultEmail() + .then (defaultEmailDetails) -> return defaultEmailDetails?.email or null .catch () -> null ) diff --git a/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee b/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee index cbcadf7e67..ca1ffef168 100644 --- a/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee +++ b/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee @@ -31,6 +31,10 @@ define [ $http.get "/user/emails" .then (response) -> response.data + getUserDefaultEmail = () -> + getUserEmails().then (userEmails) -> + _.find userEmails, (userEmail) -> userEmail.default + getUniversitiesFromCountry = (country) -> if universities[country.code]? universitiesFromCountry = universities[country.code] @@ -118,6 +122,7 @@ define [ getDefaultRoleHints getDefaultDepartmentHints getUserEmails + getUserDefaultEmail getUniversitiesFromCountry getUniversityDomainFromPartialDomainInput getUniversityDetails From 7a253e56ef94b90175b037a4b1384de9fc4cf9d8 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 21 Aug 2018 09:24:48 +0100 Subject: [PATCH 10/11] Download all log files from compiles.sharelatex.env (#833) * add a couple of missing buildPdfDownloadUrl * only download pdfs from compile server when streaming * use compiles.env for resonse files * update config to use clsi_lb --- services/web/config/settings.defaults.coffee | 3 ++- .../coffee/ide/pdf/controllers/PdfController.coffee | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index 832c3855b5..59d6e0aa89 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -135,6 +135,7 @@ module.exports = settings = url: "http://#{process.env['FILESTORE_HOST'] or 'localhost'}:3009" clsi: url: "http://#{process.env['CLSI_HOST'] or 'localhost'}:3013" + # url: "http://#{process.env['CLSI_LB_HOST']}:3014" backendGroupName: undefined templates: url: "http://#{process.env['TEMPLATES_HOST'] or 'localhost'}:3007" @@ -340,7 +341,7 @@ module.exports = settings = # disablePerUserCompiles: true # Domain the client (pdfjs) should download the compiled pdf from - # pdfDownloadDomain: "http://compiles.sharelatex.test:3014" + # pdfDownloadDomain: "http://clsi-lb:3014" # Maximum size of text documents in the real-time editing system. max_doc_length: 2 * 1024 * 1024 # 2mb diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index c717ef6b82..40264e1be0 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -225,7 +225,8 @@ define [ }, {params: params} buildPdfDownloadUrl = (pdfDownloadDomain, path)-> - if pdfDownloadDomain? + #we only download builds from compiles server for security reasons + if pdfDownloadDomain? and path.indexOf("build") != -1 return "#{pdfDownloadDomain}#{path}" else return path @@ -378,14 +379,15 @@ define [ compileGroup:ide.compileGroup clsiserverid:ide.clsiServerId if file?.url? # FIXME clean this up when we have file.urls out consistently - opts.url = buildPdfDownloadUrl options.pdfDownloadDomain, file.url + opts.url = file.url else if file?.build? - opts.url = buildPdfDownloadUrl options.pdfDownloadDomain, "/project/#{$scope.project_id}/build/#{file.build}/output/#{name}" + opts.url = "/project/#{$scope.project_id}/build/#{file.build}/output/#{name}" else - opts.url = buildPdfDownloadUrl options.pdfDownloadDomain, "/project/#{$scope.project_id}/output/#{name}" + opts.url = "/project/#{$scope.project_id}/output/#{name}" # check if we need to bust cache (build id is unique so don't need it in that case) if not file?.build? opts.params.cache_bust = "#{Date.now()}" + opts.url = buildPdfDownloadUrl options.pdfDownloadDomain, opts.url return $http(opts) # accumulate the log entries From 473063cf3d2006cad75947d3a0a6013a82531cc6 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 21 Aug 2018 10:36:18 +0100 Subject: [PATCH 11/11] set rclient.expire for server ttl even when there is no server id --- .../web/app/coffee/Features/Compile/ClsiCookieManager.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/Compile/ClsiCookieManager.coffee b/services/web/app/coffee/Features/Compile/ClsiCookieManager.coffee index 2bee2ba5e6..f2c982a077 100644 --- a/services/web/app/coffee/Features/Compile/ClsiCookieManager.coffee +++ b/services/web/app/coffee/Features/Compile/ClsiCookieManager.coffee @@ -49,7 +49,7 @@ module.exports = (backendGroup)-> return callback() serverId = @_parseServerIdFromResponse(response) if !serverId? # We don't get a cookie back if it hasn't changed - return callback() + return rclient.expire(@buildKey(project_id), Settings.clsiCookie.ttl, callback) if rclient_secondary? @_setServerIdInRedis rclient_secondary, project_id, serverId @_setServerIdInRedis rclient, project_id, serverId, (err) ->