Просмотр исходного кода

lowercase and trim add user to group email address

Henry Oswald 10 лет назад
Родитель
Сommit
43102e0ffc

+ 1 - 1
services/web/app/coffee/Features/Subscription/SubscriptionGroupController.coffee

@@ -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?

+ 2 - 2
services/web/test/UnitTests/coffee/Subscription/SubscriptionGroupControllerTests.coffee

@@ -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