You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ISSUES THAT DO NOT FOLLOW THIS TEMPLATE WILL BE CLOSED IMMEDIATELY.
This is not a usage question.
Our volunteers' time is limited, so please ask usage questions on StackOverflow.
This is not a security issue.
Do not disclose security issues in public. See our contributing
guide
for instructions.
This bug is reproducible with a clean install of authlogic
I am committed to fixing this in a reasonable amount of time, and
responding promptly to feedback.
Expected Behavior
I'm trying to create a middleware to manage user permissions. To do this, I would like to use Authlogic and retrieve the logged-in user from the session, or if not, take action in this case.
Actual Behavior
I'm using the most recent version of Authlogic (Authlogic 6.4.3), Ruby 3.3.5, and Rails 7.1.4.
I couldn't find instructions on how to use Authlogic with Rack in any tutorial, but I found comments in the file "/lib/authlogic/controller_adapters/rack_adapter.rb".
# config/application.rbrequire_relative"boot"require"rails/all"require_relative'../app/middlewares/rules_permissions'# Require the gems listed in Gemfile, including any gems# you've limited to :test, :development, or :production.Bundler.require(*Rails.groups)moduleOnlineCoursesclassApplication < Rails::Application# Initialize configuration defaults for originally generated Rails version.config.load_defaults7.1# Please, add to the `ignore` list any other `lib` subdirectories that do# not contain `.rb` files, or that should not be reloaded or eager loaded.# Common ones are `templates`, `generators`, or `middleware`, for example.config.autoload_lib(ignore: %w(assetstasks))# config.autoload_paths += %W(#{config.root}/lib)# Configuration for the application, engines, and railties goes here.## These settings can be overridden in specific environments using the files# in config/environments, which are processed later.## config.time_zone = "Central Time (US & Canada)"# config.eager_load_paths << Rails.root.join("extras")# config.time_zone = "America/Sao_Paulo"config.time_zone=ActiveSupport::TimeZone[Time.now.strftime('%z').gsub('0','').to_i]config.active_record.default_timezone=:localconfig.assets.compile=trueconfig.middleware.useRulesPermissionsendend
# app/middlewares/rules_permissions.rbclassRulesPermissionsdefinitialize(app)@app=appenddefcall(env)RulesPermissionsRackAdapter.new(env)puts'Play here';ifUserSession.find# do somethingend@app.call(env)endend
# app/models/user.rbclassUser < ApplicationRecordacts_as_authenticdo |c|
c.crypto_provider=Authlogic::CryptoProviders::BCryptc.require_password_confirmation=trueend# Validate email, login, and password as you see fit.## Authlogic < 5 added these validation for you, making them a little awkward# to change. In 4.4.0, those automatic validations were deprecated. See# https://github.com/binarylogic/authlogic/blob/master/doc/use_normal_rails_validation.mdvalidates:email,format: {with: /@/,message: "should look like an email address."},length: {maximum: 100},uniqueness: {case_sensitive: false,if: :will_save_change_to_email?}validates:password,confirmation: {if: :require_password?},length: {minimum: 8,if: :require_password?}validates:password_confirmation,length: {minimum: 8,if: :require_password?}end
ISSUES THAT DO NOT FOLLOW THIS TEMPLATE WILL BE CLOSED IMMEDIATELY.
StackOverflow.
guide
for instructions.
responding promptly to feedback.
Expected Behavior
I'm trying to create a middleware to manage user permissions. To do this, I would like to use Authlogic and retrieve the logged-in user from the session, or if not, take action in this case.
Actual Behavior
I'm using the most recent version of Authlogic (Authlogic 6.4.3), Ruby 3.3.5, and Rails 7.1.4.
I couldn't find instructions on how to use Authlogic with Rack in any tutorial, but I found comments in the file "/lib/authlogic/controller_adapters/rack_adapter.rb".
authlogic/lib/authlogic/controller_adapters/rack_adapter.rb
Lines 5 to 40 in 8e3debe
I followed the steps described here, but it returns an error:
Replicable files:
The text was updated successfully, but these errors were encountered: