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

Function createAccount

ozaria/site/store/StudentAuthStoreModule.js:48–92  ·  view source on GitHub ↗
({ state, commit, dispatch, rootState })

Source from the content-addressed store, hash-verified

46 },
47 actions: {
48 async createAccount ({ state, commit, dispatch, rootState }) {
49 const signupForm = _.omit(state.signupForm, (attr) => attr === '')
50 const ssoAttrs = _.omit(state.ssoAttrs, (attr) => attr === '')
51 const attrs = _.assign({}, signupForm, ssoAttrs, { userID: rootState.me._id })
52 if (state.ssoUsed === 'gplus') {
53 await api.users.signupWithGPlus(attrs)
54 } else if (state.ssoUsed === 'facebook') {
55 await api.users.signupWithFacebook(attrs)
56 } else {
57 await api.users.signupWithPassword(attrs)
58 }
59
60 // update User
61 const saveOptions = {
62 firstName: state.signupForm.firstName || state.ssoAttrs.firstName,
63 lastName: state.signupForm.lastName || state.ssoAttrs.lastName,
64 role: 'student'
65 }
66 saveOptions.emails = _.assign({}, me.get('emails'))
67 saveOptions.emails.generalNews = saveOptions.emails.generalNews || {}
68 if (me.inEU()) {
69 saveOptions.emails.generalNews.enabled = false
70 saveOptions.unsubscribedFromMarketingEmails = true
71 } else if (state.email) {
72 saveOptions.emails.generalNews.enabled = true
73 }
74
75 if (state.isHourOfCode) {
76 saveOptions.hourOfCode = true
77 saveOptions.hourOfCode2019 = true
78 if (!state.classCode) {
79 saveOptions.hourOfCodeOptions = _.assign({}, me.get('hourOfCodeOptions'))
80 saveOptions.hourOfCodeOptions.showHocProgress = true
81 saveOptions.hourOfCodeOptions.hocCodeLanguage = 'python' // default language
82 }
83 }
84
85 await dispatch('me/save', saveOptions, {
86 root: true
87 })
88
89 if (window.tracker && !User.isSmokeTestUser({ email: state.email })) {
90 window.tracker.identify()
91 }
92 },
93 async joinClass ({ state }) {
94 if (state.classCode && state.classroom) {
95 const classroom = new Classroom(state.classroom)

Callers

nothing calls this directly

Calls 8

dispatchFunction · 0.85
signupWithGPlusMethod · 0.80
signupWithFacebookMethod · 0.80
signupWithPasswordMethod · 0.80
inEUMethod · 0.80
isSmokeTestUserMethod · 0.80
getMethod · 0.45
identifyMethod · 0.45

Tested by

no test coverage detected