跳至內容 跳至搜尋
方法
H

執行個體公開方法

http_basic_authenticate_with(name:, password:, realm: nil, **options)

啟用 HTTP Basic 驗證。

請參閱 ActionController::HttpAuthentication::Basic 以取得範例用法。

# File actionpack/lib/action_controller/metal/http_authentication.rb, line 79
def http_basic_authenticate_with(name:, password:, realm: nil, **options)
  raise ArgumentError, "Expected name: to be a String, got #{name.class}" unless name.is_a?(String)
  raise ArgumentError, "Expected password: to be a String, got #{password.class}" unless password.is_a?(String)
  before_action(options) { http_basic_authenticate_or_request_with name: name, password: password, realm: realm }
end