def post(self, user_id): parser = reqparse.RequestParser() parser.add_argument('password', dest='password', required=True) parser.add_argument('new_email', dest='new_email', required=False) args = parser.parse_args() user = get_authenticated_user(user_id, args.password) try: edit_email(user, args.new_email, user) session.session.commit() except IllegalEmailError as e: abort(400, 'Invalid email address.') return "Email has been changed."
def post(self, user_id): parser = reqparse.RequestParser() parser.add_argument('password', type=str, required=True) parser.add_argument('new_email', type=str, required=True) parser.add_argument('forwarded', type=inputs.boolean, required=False, default=True) args = parser.parse_args() user = get_authenticated_user(user_id, args.password) try: edit_email(user, args.new_email, args.forwarded, processor=user) session.session.commit() except IllegalEmailError as e: abort(400, message='Invalid email address.') return "Email has been changed."
def test_0020_email_zero_length(self): old_email = self.user.email UserHelper.edit_email(self.user, "", self.user) self.assertEqual(self.user.email, old_email)
def test_0010_correct_new_email(self): UserHelper.edit_email(self.user, "*****@*****.**", self.user) self.assertEqual(self.user.email, "*****@*****.**")
def test_0010_correct_new_email(self): new_mail = "*****@*****.**" self.assertNotEqual(new_mail, self.user.email) UserHelper.edit_email(self.user, new_mail, self.user) self.assertEqual(self.user.email, new_mail)