MCPcopy Index your code
hub / github.com/codecombat/codecombat / init

Function init

app/core/auth.js:22–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20}
21
22const init = function () {
23 module.exports.me = (window.me = new User(window.userObject)) // inserted into main.html
24 module.exports.me.onLoaded()
25
26 trackFirstArrival()
27 if (isOzaria) {
28 addLoggerGlobalContext('userId', window.me.get('_id'))
29 }
30
31 // set country and geo fields for returning users if not set during account creation (/server/models/User - makeNew)
32 if (!me.get('country') || !me.get('geo')?.timeZone) {
33 api.users.setCountryGeo()
34 .then(function (res) {
35 me.set(res)
36 return setTestGroupNumberUS()
37 }).catch(e => console.error('Error in setting country and geo:', e))
38 }
39 if (me && (me.get('testGroupNumber') == null)) {
40 // Assign testGroupNumber to returning visitors; new ones in server/routes/auth
41 me.set('testGroupNumber', Math.floor(Math.random() * 256))
42 me.patch()
43 }
44 setTestGroupNumberUS()
45 const preferredLanguage = getQueryVariable('preferredLanguage')
46 if (me && preferredLanguage) {
47 me.set('preferredLanguage', preferredLanguage)
48 me.save()
49 }
50
51 return Backbone.listenTo(me, 'sync', () => Backbone.Mediator.publish('auth:me-synced', { me }))
52}
53
54module.exports.logoutUser = function (options) {
55 if (options == null) { options = {} }

Callers 1

auth.jsFile · 0.70

Calls 11

trackFirstArrivalFunction · 0.85
addLoggerGlobalContextFunction · 0.85
setTestGroupNumberUSFunction · 0.85
getQueryVariableFunction · 0.85
patchMethod · 0.80
publishMethod · 0.80
onLoadedMethod · 0.45
getMethod · 0.45
setMethod · 0.45
errorMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected