mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 10:06:08 -05:00
Merge pull request #920 from codecombat/master
Merge master into production
This commit is contained in:
commit
daca71786a
7 changed files with 43 additions and 60 deletions
|
@ -9,9 +9,9 @@ module.exports = LinkedInHandler = class LinkedInHandler extends CocoClass
|
|||
super()
|
||||
|
||||
subscriptions:
|
||||
'linkedin-loaded':'onLinkedInLoaded'
|
||||
'linkedin-loaded': 'onLinkedInLoaded'
|
||||
|
||||
onLinkedInLoaded: (e) =>
|
||||
onLinkedInLoaded: (e) ->
|
||||
IN.Event.on IN, "auth", @onLinkedInAuth
|
||||
|
||||
onLinkedInAuth: (e) => console.log "Authorized with LinkedIn"
|
||||
|
@ -23,6 +23,5 @@ module.exports = LinkedInHandler = class LinkedInHandler extends CocoClass
|
|||
.result (profiles) =>
|
||||
cb null, profiles.values[0]
|
||||
|
||||
|
||||
destroy: ->
|
||||
super()
|
||||
|
|
|
@ -34,6 +34,7 @@ UserSchema = c.object {},
|
|||
# notifications
|
||||
anyNotes: { $ref: '#/definitions/emailSubscription' } # overrides any other notifications settings
|
||||
recruitNotes: { $ref: '#/definitions/emailSubscription' }
|
||||
employerNotes: { $ref: '#/definitions/emailSubscription' }
|
||||
|
||||
# server controlled
|
||||
permissions: c.array {'default': []}, c.shortString()
|
||||
|
@ -112,7 +113,7 @@ UserSchema = c.object {},
|
|||
signedEmployerAgreement: c.object {},
|
||||
linkedinID: c.shortString {title:"LinkedInID", description: "The user's LinkedIn ID when they signed the contract."}
|
||||
date: c.date {title: "Date signed employer agreement"}
|
||||
data: c.object
|
||||
data: c.object {description: "Cached LinkedIn data slurped from profile."}
|
||||
|
||||
|
||||
c.extendBasicProperties UserSchema, 'user'
|
||||
|
|
|
@ -63,6 +63,6 @@ block modal-footer
|
|||
button.btn.btn-primary(id="contract-agreement-button") I agree
|
||||
else
|
||||
.modal-footer.linkedin
|
||||
| Thanks #{firstName}! You've already agreed to the contract.
|
||||
| Thanks! You've already agreed to the contract.
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ module.exports = class EmployersView extends View
|
|||
getRenderData: ->
|
||||
c = super()
|
||||
c.candidates = @candidates.models
|
||||
userPermissions = me.get('permissions') || []
|
||||
userPermissions = me.get('permissions') ? []
|
||||
|
||||
c.isEmployer = _.contains userPermissions, "employer"
|
||||
c.moment = moment
|
||||
|
|
|
@ -38,8 +38,6 @@ module.exports = class EmployerSignupView extends View
|
|||
IN.parse()
|
||||
if me.get('anonymous')
|
||||
$(".IN-widget").get(0).addEventListener('click', @createAccount, true)
|
||||
console.log "Parsed linkedin button element!"
|
||||
console.log linkedInButtonParentElement
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
|
@ -68,43 +66,26 @@ module.exports = class EmployerSignupView extends View
|
|||
|
||||
createAccount: (e) =>
|
||||
window.tracker?.trackEvent 'Finished Employer Signup'
|
||||
console.log "Tried to create account!"
|
||||
e.stopPropagation()
|
||||
forms.clearFormAlerts(@$el)
|
||||
userObject = forms.formToObject @$el
|
||||
delete userObject.subscribe
|
||||
for key, val of me.attributes when key in ["preferredLanguage", "testGroupNumber", "dateCreated", "wizardColor1", "name", "music", "volume", "emails"]
|
||||
userObject[key] ?= val
|
||||
subscribe = true
|
||||
#TODO: Enable all email subscriptions
|
||||
|
||||
userObject.emails ?= {}
|
||||
userObject.emails.generalNews ?= {}
|
||||
userObject.emails.generalNews.enabled = subscribe
|
||||
userObject.emails.employerNotes = {enabled: true}
|
||||
res = tv4.validateMultiple userObject, User.schema
|
||||
return forms.applyErrorsToForm(@$el, res.errors) unless res.valid
|
||||
window.tracker?.trackEvent 'Finished Signup'
|
||||
@enableModalInProgress(@$el)
|
||||
auth.createUserWithoutReload userObject, null
|
||||
console.log "Authorizing with linkedin"
|
||||
IN.User.authorize(@recordUserDetails, @)
|
||||
IN.User.authorize @render, @
|
||||
|
||||
linkedInAuth: (e) =>
|
||||
linkedInAuth: (e) ->
|
||||
me.fetch()
|
||||
@reloadWhenClosed = true
|
||||
|
||||
|
||||
recordUserDetails: (e) =>
|
||||
#TODO: refactor this out
|
||||
@render()
|
||||
|
||||
destroy: ->
|
||||
reloadWhenClosed = @reloadWhenClosed
|
||||
super()
|
||||
if reloadWhenClosed
|
||||
window.location.reload()
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ UserSchema.pre('save', (next) ->
|
|||
recipient:
|
||||
address: @get 'email'
|
||||
sendwithus.api.send data, (err, result) ->
|
||||
log.error 'error', err, 'result', result if err
|
||||
log.error "sendwithus post-save error: #{err}, result: #{result}" if err
|
||||
next()
|
||||
)
|
||||
|
||||
|
|
|
@ -232,6 +232,7 @@ UserHandler = class UserHandler extends Handler
|
|||
return @sendDatabaseError(res, err) if err
|
||||
documents = (LevelSessionHandler.formatEntity(req, doc) for doc in documents)
|
||||
@sendSuccess(res, documents)
|
||||
|
||||
agreeToEmployerAgreement: (req, res) ->
|
||||
userIsAnonymous = req.user?.get('anonymous')
|
||||
if userIsAnonymous then return errors.unauthorized(res, "You need to be logged in to agree to the employer agreeement.")
|
||||
|
@ -257,6 +258,7 @@ UserHandler = class UserHandler extends Handler
|
|||
if err? then return errors.serverError(res, "There was an issue updating the user object to reflect employer status: #{err}")
|
||||
res.send({"message": "The agreement was successful."})
|
||||
res.end()
|
||||
|
||||
getCandidates: (req, res) ->
|
||||
authorized = req.user.isAdmin() or ('employer' in req.user.get('permissions'))
|
||||
since = (new Date((new Date()) - 2 * 30.4 * 86400 * 1000)).toISOString()
|
||||
|
|
Loading…
Reference in a new issue