lowercase and trim add user to group email address

This commit is contained in:
Henry Oswald 2016-02-25 14:15:56 +00:00
parent 155831c3e7
commit 43102e0ffc
2 changed files with 3 additions and 3 deletions

View file

@ -12,7 +12,7 @@ module.exports =
addUserToGroup: (req, res)->
adminUserId = req.session.user._id
newEmail = req.body.email
newEmail = req.body?.email?.toLowerCase()?.trim()
logger.log adminUserId:adminUserId, newEmail:newEmail, "adding user to group subscription"
SubscriptionGroupHandler.addUserToGroup adminUserId, newEmail, (err, user)->
if err?

View file

@ -54,11 +54,11 @@ describe "SubscriptionGroupController", ->
describe "addUserToGroup", ->
it "should use the admin id for the logged in user and take the email address from the body", (done)->
newEmail = "31231"
newEmail = " boB@gmaiL.com "
@req.body = email: newEmail
res =
json : (data)=>
@GroupHandler.addUserToGroup.calledWith(@adminUserId, newEmail).should.equal true
@GroupHandler.addUserToGroup.calledWith(@adminUserId, "bob@gmail.com").should.equal true
data.user.should.deep.equal @user
done()
@Controller.addUserToGroup @req, res