Add linked accounts section to user settings page (#1705)
Add linked accounts section to user settings page GitOrigin-RevId: d2bb26a3bfb3946144a05b98f58d50a2c57f3040
This commit is contained in:
committed by
sharelatex
parent
e2793f659c
commit
54186d9db1
@@ -33,6 +33,8 @@ define([
|
||||
'main/affiliations/components/affiliationForm',
|
||||
'main/affiliations/controllers/UserAffiliationsController',
|
||||
'main/affiliations/factories/UserAffiliationsDataService',
|
||||
'main/oauth/factories/UserOauthDataService',
|
||||
'main/oauth/controllers/UserOauthController',
|
||||
'main/keys',
|
||||
'main/cms/blog',
|
||||
'main/cms/index',
|
||||
|
||||
@@ -20,12 +20,14 @@ define(['base'], function(App) {
|
||||
'$modal',
|
||||
'event_tracking',
|
||||
'UserAffiliationsDataService',
|
||||
'UserOauthDataService',
|
||||
function(
|
||||
$scope,
|
||||
$http,
|
||||
$modal,
|
||||
event_tracking,
|
||||
UserAffiliationsDataService
|
||||
UserAffiliationsDataService,
|
||||
UserOauthDataService
|
||||
) {
|
||||
$scope.subscribed = true
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
define(['base'], App =>
|
||||
App.controller('UserOauthController', [
|
||||
'$scope',
|
||||
'$q',
|
||||
'_',
|
||||
'UserOauthDataService',
|
||||
function($scope, $q, _, UserOauthDataService) {
|
||||
$scope.providers = [
|
||||
{ key: 'google', name: 'Google' },
|
||||
{ key: 'orcid', name: 'Orcid' },
|
||||
{ key: 'twitter', name: 'Twitter' }
|
||||
]
|
||||
const _monitorRequest = function(promise) {
|
||||
$scope.ui.hasError = false
|
||||
$scope.ui.isLoadingProviders = true
|
||||
promise
|
||||
.catch(response => {
|
||||
$scope.ui.hasError = true
|
||||
$scope.ui.errorMessage =
|
||||
response && response.data && response.data.message
|
||||
? response.data.message
|
||||
: 'error'
|
||||
})
|
||||
.finally(() => {
|
||||
$scope.ui.isLoadingProviders = false
|
||||
})
|
||||
return promise
|
||||
}
|
||||
const _reset = function() {
|
||||
$scope.ui = {
|
||||
hasError: false,
|
||||
errorMessage: '',
|
||||
isLoadingProviders: false
|
||||
}
|
||||
$scope.userProviders = {}
|
||||
}
|
||||
const _getUserV1OauthProviders = () => {
|
||||
$scope.ui.isLoadingProviders = true
|
||||
return _monitorRequest(UserOauthDataService.getUserOauthV1()).then(
|
||||
userProviders => {
|
||||
$scope.userProviders = userProviders
|
||||
}
|
||||
)
|
||||
}
|
||||
_reset()
|
||||
return _getUserV1OauthProviders()
|
||||
}
|
||||
]))
|
||||
@@ -0,0 +1,20 @@
|
||||
define(['base'], function(App) {
|
||||
return App.factory('UserOauthDataService', [
|
||||
'$http',
|
||||
function($http) {
|
||||
const getUserOauthV1 = () => {
|
||||
if (window.ExposedSettings.isOverleaf) {
|
||||
return $http.get('/user/v1-oauth-uids').then(response => {
|
||||
return response.data
|
||||
})
|
||||
} else {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
getUserOauthV1
|
||||
}
|
||||
}
|
||||
])
|
||||
})
|
||||
Reference in New Issue
Block a user