Sha256: 7f6696d510650ed8413dae6899c46e3f2ed420457fa6846f0f92eec31865a493

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require_relative 'command_handler'

module Ftpd

  # The login commands

  class CmdLogin < CommandHandler

    # @return [String] The user for the current login sequence

    attr_accessor :user

    # @return [String] The password for the current login sequence

    attr_accessor :password

    def initialize(*)
      super
      @user = nil
      @password = nil
    end

    #  * User Name (USER) command.

    def cmd_user(argument)
      syntax_error unless argument
      sequence_error if logged_in
      @user = argument
      if config.auth_level > AUTH_USER
        reply "331 Password required"
        expect 'pass'
      else
        login @user
      end
    end

    # The Password (PASS) command

    def cmd_pass(argument)
      syntax_error unless argument
      @password = argument
      if config.auth_level > AUTH_PASSWORD
        reply "332 Account required"
        expect 'acct'
      else
        login @user, @password
      end
    end

    # The Account (ACCT) command

    def cmd_acct(argument)
      syntax_error unless argument
      account = argument
      login @user, @password, account
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ftpd-2.1.0 lib/ftpd/cmd_login.rb
ftpd-2.0.5 lib/ftpd/cmd_login.rb
ftpd-2.0.4 lib/ftpd/cmd_login.rb
ftpd-2.0.3 lib/ftpd/cmd_login.rb
ftpd-2.0.2 lib/ftpd/cmd_login.rb
ftpd-2.0.1 lib/ftpd/cmd_login.rb
ftpd-2.0.0 lib/ftpd/cmd_login.rb