mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
1be43911b4
Set Prettier's "trailingComma" setting to "es5" GitOrigin-RevId: 9f14150511929a855b27467ad17be6ab262fe5d5
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import App from '../../../base'
|
|
|
|
export default App.controller(
|
|
'UserOauthController',
|
|
function ($http, $scope, $q) {
|
|
const _reset = function () {
|
|
$scope.ui = {
|
|
hasError: false,
|
|
errorMessage: '',
|
|
}
|
|
$scope.providers = window.oauthProviders
|
|
$scope.thirdPartyIds = window.thirdPartyIds
|
|
}
|
|
const _unlinkError = (providerId, err) => {
|
|
$scope.providers[providerId].ui.hasError = true
|
|
$scope.providers[providerId].ui.errorMessage =
|
|
err && err.data && err.data.message ? err.data.message : 'error'
|
|
}
|
|
|
|
$scope.unlink = providerId => {
|
|
if (window.ExposedSettings.isOverleaf) {
|
|
// UI
|
|
$scope.providers[providerId].ui = {
|
|
hasError: false,
|
|
isProcessing: true,
|
|
}
|
|
// Data for update
|
|
const data = {
|
|
_csrf: window.csrfToken,
|
|
link: false,
|
|
providerId,
|
|
}
|
|
$http
|
|
.post('/user/oauth-unlink', data)
|
|
.catch(error => {
|
|
$scope.providers[providerId].ui.isProcessing = false
|
|
_unlinkError(providerId, error)
|
|
})
|
|
.then(response => {
|
|
$scope.providers[providerId].ui.isProcessing = false
|
|
if (response.status === 200) {
|
|
$scope.thirdPartyIds[providerId] = null
|
|
} else {
|
|
_unlinkError(providerId, response)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
_reset()
|
|
}
|
|
)
|