Use v2 data for OAuth providers

GitOrigin-RevId: 09df3253c283b3196bc48a0440e9ea5f1eb20c9c
This commit is contained in:
Jessica Lawshe 2019-06-18 16:01:52 -05:00 committed by sharelatex
parent 6f40fd9b99
commit 0a2a32120f
2 changed files with 2 additions and 39 deletions

View file

@ -1,12 +1,11 @@
block scripts block scripts
script(type='text/javascript'). script(type='text/javascript').
window.oauthUseV2 = #{oauthUseV2}
window.oauthProviders = !{StringHelper.stringifyJsonForScript(oauthProviders)} window.oauthProviders = !{StringHelper.stringifyJsonForScript(oauthProviders)}
window.thirdPartyIds = !{StringHelper.stringifyJsonForScript(thirdPartyIds)} window.thirdPartyIds = !{StringHelper.stringifyJsonForScript(thirdPartyIds)}
mixin providerList() mixin providerList()
ul.list-like-table ul.list-like-table
li(ng-repeat="(key, provider) in providers" ng-if="!provider.hideWhenNotLinked || (key == 'collabratec' && v2ThirdPartyIds[key]) || (provider.hideWhenNotLinked && thirdPartyIds[key])") li(ng-repeat="(key, provider) in providers" ng-if="!provider.hideWhenNotLinked || (provider.hideWhenNotLinked && thirdPartyIds[key])")
.row .row
.col-xs-12.col-sm-8.col-md-10 .col-xs-12.col-sm-8.col-md-10
h4 {{provider.name}} h4 {{provider.name}}
@ -16,7 +15,7 @@ mixin providerList()
button.btn.btn-default( button.btn.btn-default(
ng-click="unlink(key)" ng-click="unlink(key)"
ng-disabled="providers[key].ui.isProcessing" ng-disabled="providers[key].ui.isProcessing"
ng-if="thirdPartyIds[key] || (key == 'collabratec' && v2ThirdPartyIds[key])" ng-if="thirdPartyIds[key]"
) )
span(ng-if="!providers[key].ui.isProcessing") #{translate("unlink")} span(ng-if="!providers[key].ui.isProcessing") #{translate("unlink")}
span(ng-if="providers[key].ui.isProcessing") #{translate("processing")} span(ng-if="providers[key].ui.isProcessing") #{translate("processing")}

View file

@ -6,22 +6,6 @@ define(['base'], App =>
_, _,
UserOauthDataService UserOauthDataService
) { ) {
const _monitorRequest = function(promise) {
$scope.ui.hasError = false
$scope.ui.isLoadingV1Ids = true
promise
.catch(response => {
$scope.ui.hasError = true
$scope.ui.errorMessage =
response && response.data && response.data.message
? response.data.message
: 'error'
})
.finally(() => {
$scope.ui.isLoadingV1Ids = false
})
return promise
}
const _reset = function() { const _reset = function() {
$scope.ui = { $scope.ui = {
hasError: false, hasError: false,
@ -30,21 +14,6 @@ define(['base'], App =>
} }
$scope.providers = window.oauthProviders $scope.providers = window.oauthProviders
$scope.thirdPartyIds = window.thirdPartyIds $scope.thirdPartyIds = window.thirdPartyIds
// 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 = () => {
$scope.ui.isLoadingV1Ids = true
return _monitorRequest(UserOauthDataService.getUserOauthV1()).then(
thirdPartyIds => {
$scope.thirdPartyIds = thirdPartyIds
}
)
} }
const _unlinkError = (providerId, err) => { const _unlinkError = (providerId, err) => {
$scope.providers[providerId].ui.hasError = true $scope.providers[providerId].ui.hasError = true
@ -75,8 +44,6 @@ define(['base'], App =>
$scope.providers[providerId].ui.isProcessing = false $scope.providers[providerId].ui.isProcessing = false
if (response.status === 200) { if (response.status === 200) {
$scope.thirdPartyIds[providerId] = null $scope.thirdPartyIds[providerId] = null
// v2thirdPartyIds below can be removed post user c11n
$scope.v2ThirdPartyIds[providerId] = null
} else { } else {
_unlinkError(providerId, response) _unlinkError(providerId, response)
} }
@ -85,7 +52,4 @@ define(['base'], App =>
} }
_reset() _reset()
if (!window.oauthUseV2) {
_getUserV1OauthProviders()
}
})) }))