You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: unregistered_user.rb
    path of file: ./repos/open-build-service/src/api/app/models
    
    the code of the file until where you have to start completion: require 'api_error'

class UnregisteredUser < User
  class ErrRegisterSave < APIError
  end

  # Raises an exception if registration is disabled for a user
  # Returns true if a user can register
  def self.can_register?
    # No registering if LDAP is on
    if CONFIG['ldap_mode'] == :on && !User.admin_session?
      logger.debug 'Someone tried to register with "ldap_mode" turned on'
      raise ErrRegisterSave, 'Sorry, new users c
    
  def self.register(opts)
    can_register?

    opts[:note] = nil unless User.admin_session?
    state = ::Configuration.registration == 'allow' ? 'confirmed' : 'unconfirmed'

    newuser = User.new(
      realname: opts[:realname] || '',
      login: opts[:login],
      password: opts[:password],
      password_confirmation: opts[:password_confirmation],
      email: opts[:email],
      state: state,
      adminnote: opts[:note],
      ignore_auth_services: Configuration.ldap_enabled?
    )

    raise ErrRegisterSave, "Could not save the registration, details: #{newuser.errors.full_messages.to_sentence}" unless newuser.save

    return unless newuser.state == 'unconfirmed'

    raise ErrRegisterSave, 'Thank you for signing up! An admin has to confirm your account now. Please be patient.'
  end