Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handlers: Fix post users #3273

Merged
merged 4 commits into from
Jan 13, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions redash/handlers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def post(self):
req = request.get_json(force=True)
require_fields(req, ('name', 'email'))

if '@' not in req['email']:
abort(400, message='Bad email address.!!!')
kravets-levko marked this conversation as resolved.
Show resolved Hide resolved
name, domain = req['email'].split('@', 1)

if domain.lower() in blacklist or domain.lower() == 'qq.com':
Expand Down
3 changes: 3 additions & 0 deletions tests/handlers/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def test_returns_400_when_missing_fields(self):
rv = self.make_request('post', '/api/users', data={'name': 'User'}, user=admin)
self.assertEqual(rv.status_code, 400)

rv = self.make_request('post', '/api/users', data={'name': 'User', 'email': 'bademailaddress'}, user=admin)
self.assertEqual(rv.status_code, 400)

def test_returns_400_when_using_temporary_email(self):
admin = self.factory.create_admin()

Expand Down