Merge hotfix for sending course invite emails

This commit is contained in:
phoenixeliot 2016-06-06 13:44:15 -07:00
commit dd17c39708
2 changed files with 4 additions and 3 deletions

View file

@ -124,7 +124,7 @@ module.exports = class Classroom extends CocoModel
inviteMembers: (emails, options={}) ->
options.data ?= {}
options.data.email = emails
options.data.emails = emails
options.url = @url() + '/invite-members'
options.type = 'POST'
@fetch(options)

View file

@ -221,14 +221,15 @@ module.exports =
inviteMembers: wrap (req, res) ->
if not req.body.emails
log.debug "classrooms.inviteMembers: No emails included in request: #{JSON.stringify(req.body)}"
throw new errors.UnprocessableEntity('Emails not included')
classroom = yield database.getDocFromHandle(req, Classroom)
if not classroom
throw new errors.NotFound('Classroom not found.')
unless classroom.get('ownerID').equals(req.user?._id)
log.debug "classroom_handler.inviteStudents: Can't invite to classroom (#{classroom.id}) you (#{req.user.get('_id')}) don't own"
log.debug "classroom_handler.inviteMembers: Can't invite to classroom (#{classroom.id}) you (#{req.user.get('_id')}) don't own"
throw new errors.Forbidden('Must be owner of classroom to send invites.')
for email in req.body.emails