diff --git a/endpoints/index.py b/endpoints/index.py index 2e690095f..c6bbebbe5 100644 --- a/endpoints/index.py +++ b/endpoints/index.py @@ -110,39 +110,17 @@ def create_user(): abort(400, 'Invalid robot account or password.', issue='robot-login-failure') - if authentication.user_exists(username): - (verified, error_message) = authentication.verify_user(username, password, basic_auth=True) - if verified: - # Mark that the user was logged in. - event = userevents.get_event(username) - event.publish_event_data('docker-cli', {'action': 'login'}) - return success - else: - # Mark that the login failed. - event = userevents.get_event(username) - event.publish_event_data('docker-cli', {'action': 'loginfailure'}) - abort(400, error_message, issue='login-failure') - - elif not features.USER_CREATION: - abort(400, 'User creation is disabled. Please speak to your administrator.') - + (verified, error_message) = authentication.verify_user(username, password, basic_auth=True) + if verified: + # Mark that the user was logged in. + event = userevents.get_event(username) + event.publish_event_data('docker-cli', {'action': 'login'}) + return success else: - # New user case - logger.debug('Creating user') - new_user = None - - try: - new_user = model.create_user(username, password, user_data['email']) - except model.TooManyUsersException as ex: - abort(402, 'Seat limit has been reached for this license', issue='seat-limit') - - logger.debug('Creating email code for user') - code = model.create_confirm_email_code(new_user) - - logger.debug('Sending email code to user') - send_confirmation_email(new_user.username, new_user.email, code.code) - - return make_response('Created', 201) + # Mark that the login failed. + event = userevents.get_event(username) + event.publish_event_data('docker-cli', {'action': 'loginfailure'}) + abort(400, error_message, issue='login-failure') @index.route('/users', methods=['GET']) diff --git a/test/specs.py b/test/specs.py index 8749a025e..f8a4e491b 100644 --- a/test/specs.py +++ b/test/specs.py @@ -160,8 +160,8 @@ def build_index_specs(): IndexTestSpec(url_for('registry.put_image_json', image_id=FAKE_IMAGE_ID), ORG_REPO, 403, 403, 403, 400).set_method('PUT'), - IndexTestSpec(url_for('index.create_user'), NO_REPO, 201, 201, 201, - 201).set_method('POST').set_data_from_obj(NEW_USER_DETAILS), + IndexTestSpec(url_for('index.create_user'), NO_REPO, 400, 400, 400, + 400).set_method('POST').set_data_from_obj(NEW_USER_DETAILS), IndexTestSpec(url_for('index.get_user'), NO_REPO, 404, 200, 200, 200),