mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 01:25:16 +00:00
Don't allow updating user's email to blacklisted domain. (#3127)
This commit is contained in:
parent
1cdfcfaa3c
commit
bd20ce12ac
@ -184,6 +184,12 @@ class UserResource(BaseResource):
|
||||
|
||||
if 'groups' in params and not self.current_user.has_permission('admin'):
|
||||
abort(403, message="Must be admin to change groups membership.")
|
||||
|
||||
if 'email' in params:
|
||||
_, domain = params['email'].split('@', 1)
|
||||
|
||||
if domain.lower() in blacklist or domain.lower() == 'qq.com':
|
||||
abort(400, message='Bad email address.')
|
||||
|
||||
try:
|
||||
self.update_model(user, params)
|
||||
|
@ -149,6 +149,17 @@ class TestUserResourcePost(BaseTestCase):
|
||||
|
||||
user = models.User.query.get(self.factory.user.id)
|
||||
self.assertTrue(user.verify_password(new_password))
|
||||
|
||||
def test_returns_400_when_using_temporary_email(self):
|
||||
admin = self.factory.create_admin()
|
||||
|
||||
test_user = {'email': 'user@mailinator.com'}
|
||||
rv = self.make_request('post', '/api/users/{}'.format(self.factory.user.id), data=test_user, user=admin)
|
||||
self.assertEqual(rv.status_code, 400)
|
||||
|
||||
test_user['email'] = 'arik@qq.com'
|
||||
rv = self.make_request('post', '/api/users', data=test_user, user=admin)
|
||||
self.assertEqual(rv.status_code, 400)
|
||||
|
||||
|
||||
class TestUserDisable(BaseTestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user