diff --git a/timesketch/api/v1/resources.py b/timesketch/api/v1/resources.py index 210f0d1968..fc181f3af0 100644 --- a/timesketch/api/v1/resources.py +++ b/timesketch/api/v1/resources.py @@ -2426,9 +2426,15 @@ def post(self, sketch_id): 'The user does not have write permission on the sketch.') for username in form.get('users', []): - base_username = username.split('@')[0] - base_username = base_username.strip() - user = User.query.filter_by(username=base_username).first() + # Try the username with any potential @domain preserved. + user = User.query.filter_by(username=username).first() + + # If no hit, then try to strip the domain. + if not user: + base_username = username.split('@')[0] + base_username = base_username.strip() + user = User.query.filter_by(username=base_username).first() + if user: sketch.grant_permission(permission='read', user=user) sketch.grant_permission(permission='write', user=user)