Просмотр исходного кода

Merge pull request #1895 from overleaf/jel-oauth-db-flip

Add setting var for OAuth data source

GitOrigin-RevId: e8a2ce588c7b5c8a9cf2c782d0434b421df7b356
Simon Detheridge 7 лет назад
Родитель
Сommit
bd3f59c22a

+ 1 - 0
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

+ 2 - 2
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")}...

+ 7 - 6
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()
       }
     }