Merge pull request #2021 from coreos-inc/few-many-users
Delete old "license" checking code arounds user counts
This commit is contained in:
commit
b624269117
4 changed files with 3 additions and 29 deletions
|
@ -45,10 +45,6 @@ class InvalidUsernameException(DataModelException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TooManyUsersException(DataModelException):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidRepositoryBuildException(DataModelException):
|
class InvalidRepositoryBuildException(DataModelException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ from data.database import (User, LoginService, FederatedLogin, RepositoryPermiss
|
||||||
UserRegion, ImageStorageLocation)
|
UserRegion, ImageStorageLocation)
|
||||||
from data.model import (DataModelException, InvalidPasswordException, InvalidRobotException,
|
from data.model import (DataModelException, InvalidPasswordException, InvalidRobotException,
|
||||||
InvalidUsernameException, InvalidEmailAddressException,
|
InvalidUsernameException, InvalidEmailAddressException,
|
||||||
TooManyUsersException, TooManyLoginAttemptsException, db_transaction,
|
TooManyLoginAttemptsException, db_transaction,
|
||||||
notification, config, repository, _basequery)
|
notification, config, repository, _basequery)
|
||||||
from util.names import format_robot_username, parse_robot_username
|
from util.names import format_robot_username, parse_robot_username
|
||||||
from util.validation import (validate_username, validate_email, validate_password,
|
from util.validation import (validate_username, validate_email, validate_password,
|
||||||
|
@ -31,18 +31,11 @@ def hash_password(password, salt=None):
|
||||||
return bcrypt.hashpw(password.encode('utf-8'), salt)
|
return bcrypt.hashpw(password.encode('utf-8'), salt)
|
||||||
|
|
||||||
|
|
||||||
def is_create_user_allowed():
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def create_user(username, password, email, auto_verify=False):
|
def create_user(username, password, email, auto_verify=False):
|
||||||
""" Creates a regular user, if allowed. """
|
""" Creates a regular user, if allowed. """
|
||||||
if not validate_password(password):
|
if not validate_password(password):
|
||||||
raise InvalidPasswordException(INVALID_PASSWORD_MESSAGE)
|
raise InvalidPasswordException(INVALID_PASSWORD_MESSAGE)
|
||||||
|
|
||||||
if not is_create_user_allowed():
|
|
||||||
raise TooManyUsersException()
|
|
||||||
|
|
||||||
created = create_user_noverify(username, email)
|
created = create_user_noverify(username, email)
|
||||||
created.password_hash = hash_password(password)
|
created.password_hash = hash_password(password)
|
||||||
created.verified = auto_verify
|
created.verified = auto_verify
|
||||||
|
@ -307,9 +300,6 @@ def list_entity_robot_permission_teams(entity_name, include_permissions=False):
|
||||||
|
|
||||||
def create_federated_user(username, email, service_name, service_ident,
|
def create_federated_user(username, email, service_name, service_ident,
|
||||||
set_password_notification, metadata={}):
|
set_password_notification, metadata={}):
|
||||||
if not is_create_user_allowed():
|
|
||||||
raise TooManyUsersException()
|
|
||||||
|
|
||||||
new_user = create_user_noverify(username, email)
|
new_user = create_user_noverify(username, email)
|
||||||
new_user.verified = True
|
new_user.verified = True
|
||||||
new_user.save()
|
new_user.save()
|
||||||
|
|
|
@ -322,10 +322,6 @@ def request_error(exception=None, **kwargs):
|
||||||
raise InvalidRequest(message, data)
|
raise InvalidRequest(message, data)
|
||||||
|
|
||||||
|
|
||||||
def license_error(exception=None):
|
|
||||||
raise ExceedsLicenseException()
|
|
||||||
|
|
||||||
|
|
||||||
def log_action(kind, user_or_orgname, metadata=None, repo=None):
|
def log_action(kind, user_or_orgname, metadata=None, repo=None):
|
||||||
if not metadata:
|
if not metadata:
|
||||||
metadata = {}
|
metadata = {}
|
||||||
|
|
|
@ -21,7 +21,7 @@ from data.database import Repository as RepositoryTable
|
||||||
from endpoints.api import (ApiResource, nickname, resource, validate_json_request, request_error,
|
from endpoints.api import (ApiResource, nickname, resource, validate_json_request, request_error,
|
||||||
log_action, internal_only, require_user_admin, parse_args,
|
log_action, internal_only, require_user_admin, parse_args,
|
||||||
query_param, require_scope, format_date, show_if,
|
query_param, require_scope, format_date, show_if,
|
||||||
license_error, require_fresh_login, path_param, define_json_response,
|
require_fresh_login, path_param, define_json_response,
|
||||||
RepositoryParamResource, page_support)
|
RepositoryParamResource, page_support)
|
||||||
from endpoints.exception import NotFound, InvalidToken
|
from endpoints.exception import NotFound, InvalidToken
|
||||||
from endpoints.api.subscribe import subscribe
|
from endpoints.api.subscribe import subscribe
|
||||||
|
@ -367,9 +367,6 @@ class User(ApiResource):
|
||||||
else:
|
else:
|
||||||
common_login(new_user)
|
common_login(new_user)
|
||||||
return user_view(new_user)
|
return user_view(new_user)
|
||||||
|
|
||||||
except model.user.TooManyUsersException as ex:
|
|
||||||
raise license_error(exception=ex)
|
|
||||||
except model.user.DataModelException as ex:
|
except model.user.DataModelException as ex:
|
||||||
raise request_error(exception=ex)
|
raise request_error(exception=ex)
|
||||||
|
|
||||||
|
@ -439,13 +436,8 @@ class ClientKey(ApiResource):
|
||||||
def conduct_signin(username_or_email, password, invite_code=None):
|
def conduct_signin(username_or_email, password, invite_code=None):
|
||||||
needs_email_verification = False
|
needs_email_verification = False
|
||||||
invalid_credentials = False
|
invalid_credentials = False
|
||||||
found_user = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
(found_user, error_message) = authentication.verify_and_link_user(username_or_email, password)
|
|
||||||
except model.user.TooManyUsersException as ex:
|
|
||||||
raise license_error(exception=ex)
|
|
||||||
|
|
||||||
|
(found_user, error_message) = authentication.verify_and_link_user(username_or_email, password)
|
||||||
if found_user:
|
if found_user:
|
||||||
# If there is an attached invitation code, handle it here. This will mark the
|
# If there is an attached invitation code, handle it here. This will mark the
|
||||||
# user as verified if the code is valid.
|
# user as verified if the code is valid.
|
||||||
|
|
Reference in a new issue