MCPcopy Create free account
hub / github.com/codecombat/codecombat / extraProvisions

Function extraProvisions

app/lib/user-utils.js:6–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4const _ = require('lodash')
5
6function extraProvisions () {
7 usersApi.extraProvisions({ userId: me.get('_id') })
8 .then(({ provisionType, ...obj }) => {
9 if (provisionType === 'library') {
10 const { premiumAdded, isInLibraryNetwork, hideEmail, libraryName, showLoginModal, isCreatedViaLibrary } = obj
11 handleStorage(libraryNetworkLSKey(), isInLibraryNetwork, 24 * 60)
12 handleStorage(hideEmailLibraryKey(), hideEmail, 24 * 60)
13 handleStorage(showLibraryLoginModalKey(), showLoginModal, 60)
14 handleStorage(isCreatedViaLibraryKey(), isCreatedViaLibrary, 24 * 60)
15 handleStorage(libraryNameKey(), libraryName, 24 * 60)
16
17 const lib = me.get('library') || {}
18 if (!lib.name && libraryName) {
19 lib.name = libraryName
20 me.set('library', lib)
21 me.save()
22 }
23 if (premiumAdded) me.fetch({ cache: false })
24 } else if (provisionType === 'teacher') {
25 const { esportsAdded } = obj
26 if (esportsAdded) me.fetch({ cache: false })
27 }
28 })
29 .catch((err) => {
30 console.error('provision err', err)
31 })
32}
33
34function handleStorage (key, value, expirationInMinutes) {
35 if (value) {

Callers

nothing calls this directly

Calls 11

handleStorageFunction · 0.85
libraryNetworkLSKeyFunction · 0.85
hideEmailLibraryKeyFunction · 0.85
showLibraryLoginModalKeyFunction · 0.85
isCreatedViaLibraryKeyFunction · 0.85
libraryNameKeyFunction · 0.85
getMethod · 0.45
setMethod · 0.45
saveMethod · 0.45
fetchMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected