2022-04-22 09:49:26 -04:00
|
|
|
const MOCK_DELAY = 1000
|
|
|
|
|
|
|
|
export function defaultSetupMocks(fetchMock) {
|
2022-04-25 07:04:44 -04:00
|
|
|
fetchMock
|
|
|
|
.post('/user/oauth-unlink', 200, { delay: MOCK_DELAY })
|
|
|
|
.get(
|
|
|
|
'express:/user/tpds/queues',
|
|
|
|
{ tpdsToWeb: 0, webToTpds: 0 },
|
|
|
|
{ delay: MOCK_DELAY }
|
|
|
|
)
|
2022-04-22 09:49:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function setDefaultMeta() {
|
2022-04-25 07:04:44 -04:00
|
|
|
window.metaAttributesCache.set('ol-user', {
|
2022-04-27 12:13:42 -04:00
|
|
|
...window.metaAttributesCache.get('ol-user'),
|
2022-04-25 07:04:44 -04:00
|
|
|
features: { github: true, dropbox: true, mendeley: false, zotero: false },
|
|
|
|
refProviders: {
|
|
|
|
mendeley: true,
|
|
|
|
zotero: true,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
window.metaAttributesCache.set('ol-github', { enabled: false })
|
|
|
|
window.metaAttributesCache.set('ol-dropbox', { registered: true })
|
2022-04-22 09:49:26 -04:00
|
|
|
window.metaAttributesCache.set('ol-thirdPartyIds', {
|
|
|
|
collabratec: 'collabratec-id',
|
|
|
|
google: 'google-id',
|
|
|
|
})
|
|
|
|
|
|
|
|
window.metaAttributesCache.set('ol-oauthProviders', {
|
|
|
|
collabratec: {
|
|
|
|
descriptionKey: 'linked_collabratec_description',
|
|
|
|
descriptionOptions: { appName: 'Overleaf' },
|
|
|
|
name: 'IEEE Collabratec®',
|
|
|
|
hideWhenNotLinked: true,
|
|
|
|
linkPath: '/collabratec/auth/link',
|
|
|
|
},
|
|
|
|
google: {
|
|
|
|
descriptionKey: 'login_with_service',
|
|
|
|
descriptionOptions: { service: 'Google' },
|
|
|
|
name: 'Google',
|
|
|
|
linkPath: '/auth/google',
|
|
|
|
},
|
|
|
|
orcid: {
|
|
|
|
descriptionKey: 'oauth_orcid_description',
|
|
|
|
descriptionOptions: {
|
|
|
|
link: '/blog/434',
|
|
|
|
appName: 'Overleaf',
|
|
|
|
},
|
2022-05-26 08:58:21 -04:00
|
|
|
name: 'ORCID',
|
2022-04-22 09:49:26 -04:00
|
|
|
linkPath: '/auth/orcid',
|
|
|
|
},
|
|
|
|
})
|
2024-06-18 06:01:37 -04:00
|
|
|
window.metaAttributesCache.set('ol-hideLinkingWidgets', true)
|
2022-05-16 04:02:17 -04:00
|
|
|
window.metaAttributesCache.delete('ol-ssoErrorMessage')
|
2022-04-22 09:49:26 -04:00
|
|
|
}
|
2023-05-17 04:59:51 -04:00
|
|
|
|
|
|
|
export function setPersonalAccessTokensMeta() {
|
|
|
|
function generateToken(_id) {
|
|
|
|
const oneYearFromNow = new Date()
|
|
|
|
oneYearFromNow.setFullYear(oneYearFromNow.getFullYear() + 1)
|
|
|
|
|
|
|
|
const tokenHasBeenUsed = Math.random() > 0.5
|
|
|
|
|
|
|
|
return {
|
|
|
|
_id,
|
|
|
|
accessTokenPartial: 'olp_abc' + _id,
|
|
|
|
createdAt: new Date(),
|
|
|
|
accessTokenExpiresAt: oneYearFromNow,
|
|
|
|
lastUsedAt: tokenHasBeenUsed ? new Date() : undefined,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const tokens = []
|
|
|
|
for (let i = 0; i < 6; i++) {
|
|
|
|
tokens.push(generateToken(i))
|
|
|
|
}
|
|
|
|
|
|
|
|
window.metaAttributesCache.set('ol-personalAccessTokens', tokens)
|
|
|
|
}
|