From bd3f59c22a2d18f872332fdd2de036b4f175a1a0 Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Tue, 25 Jun 2019 12:08:24 +0100 Subject: [PATCH] Merge pull request #1895 from overleaf/jel-oauth-db-flip Add setting var for OAuth data source GitOrigin-RevId: e8a2ce588c7b5c8a9cf2c782d0434b421df7b356 --- .../app/src/Features/User/UserPagesController.js | 1 + services/web/app/views/user/settings/user-oauth.pug | 4 ++-- .../main/oauth/controllers/UserOauthController.js | 13 +++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/services/web/app/src/Features/User/UserPagesController.js b/services/web/app/src/Features/User/UserPagesController.js index 748fd7a00a..00fbad2c48 100644 --- a/services/web/app/src/Features/User/UserPagesController.js +++ b/services/web/app/src/Features/User/UserPagesController.js @@ -160,6 +160,7 @@ module.exports = UserPagesController = { oauthProviders, req ), + oauthUseV2: Settings.oauthUseV2 || false, ssoError: ssoError, thirdPartyIds: UserPagesController._restructureThirdPartyIds(user), previewOauth: req.query.prvw != null diff --git a/services/web/app/views/user/settings/user-oauth.pug b/services/web/app/views/user/settings/user-oauth.pug index ac674c9feb..94abcddc94 100644 --- a/services/web/app/views/user/settings/user-oauth.pug +++ b/services/web/app/views/user/settings/user-oauth.pug @@ -1,6 +1,6 @@ block scripts script(type='text/javascript'). - window.oauthFallback = #{oauthFallback} + window.oauthUseV2 = #{oauthUseV2} window.oauthProviders = !{StringHelper.stringifyJsonForScript(oauthProviders)} window.thirdPartyIds = !{StringHelper.stringifyJsonForScript(thirdPartyIds)} @@ -45,7 +45,7 @@ mixin providerList() h3.text-capitalize#linked-accounts #{translate("linked_accounts")} p.small #{translate("linked_accounts_explained", {appName:'{{settings.appName}}'})} - if settings.oauthFallback + if !settings.oauthUseV2 div.text-center(ng-if="ui.isLoadingV1Ids") i.fa.fa-fw.fa-spin.fa-refresh(aria-hidden="true") |  #{translate("loading")}... diff --git a/services/web/public/src/main/oauth/controllers/UserOauthController.js b/services/web/public/src/main/oauth/controllers/UserOauthController.js index 7e9ce1ebe7..abc0417b93 100644 --- a/services/web/public/src/main/oauth/controllers/UserOauthController.js +++ b/services/web/public/src/main/oauth/controllers/UserOauthController.js @@ -30,11 +30,12 @@ define(['base'], App => } $scope.providers = window.oauthProviders $scope.thirdPartyIds = window.thirdPartyIds - // $scope.v2ThirdPartyIds can be removed post user-c11n - // until v1 is authoritative we will use v1 SSO data for providers - // except collabratec, which will only write to v2. - // post user-c11n, oauthFallback setting will be removed and - // we will only use data from v2 + // until oauthUseV2=true, we will use OAuth data via v1 DB, + // except for Collabratec, which is only writing to the v2 DB. + // $scope.v2ThirdPartyIds is required for Collabratec, + // and only until v2 is authoritative. Though, we should leave this + // until we stop double writes, in case we need to flip. + // Double writes for OAuth will stop when oauthFallback=false $scope.v2ThirdPartyIds = window.thirdPartyIds } const _getUserV1OauthProviders = () => { @@ -84,7 +85,7 @@ define(['base'], App => } _reset() - if (window.oauthFallback) { + if (!window.oauthUseV2) { _getUserV1OauthProviders() } }