示例#1
0
文件: __init__.py 项目: JuKu/pycroft
    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."
示例#2
0
文件: __init__.py 项目: agdsn/pycroft
    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."
示例#3
0
    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)
示例#4
0
    def test_0010_correct_new_email(self):
        UserHelper.edit_email(self.user, "*****@*****.**", self.user)

        self.assertEqual(self.user.email, "*****@*****.**")
示例#5
0
 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)
示例#6
0
    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)
示例#7
0
    def test_0010_correct_new_email(self):
        UserHelper.edit_email(self.user, "*****@*****.**", self.user)

        self.assertEqual(self.user.email, "*****@*****.**")
示例#8
0
 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)