merb_auth_password_slice 不维护会话

发布于 2024-07-06 21:23:32 字数 1413 浏览 8 评论 0原文

按照自述文件集成了 merb_auth_password_slice 后,我可以在触发 redirect_after_login 时成功登录,尽管 session.authenticated? 返回 false。

现在只是尝试基本的身份验证策略(密码形式),似乎无法让它工作,有什么想法吗?

我的初始化文件:

require 'dm-validations'

dependencies "merb-more", "merb_helpers", "merb-slices", "merb_auth_password_slice"


Merb::BootLoader.before_app_loads do
  DataMapper.setup(:default, "sqlite3://config/dev.db")
end

Merb::BootLoader.after_app_loads do
    # have already done this
    # raise "You must specify a valid openid in Merb.root/config/open_id to use this example app" unless File.exists?(Merb.root / "config" / "open_id")
    # # DataMapper.auto_migrate!
    # User.create(:login => "admin", 
    #             :password => "password", :password_confirmation => "password", 
    #             :email => "[email protected]", 
    #             :identity_url => File.read(Merb.root / "config" / "open_id"))
end

Merb::Config.use do |c|
  c[:session_secret_key]  = 'my key'
  c[:session_store] = 'cookie'
end

Setup.rb

class Authentication

  def store_user(user)
    return nil unless user
    user.id
  end

  def fetch_user(session_info)
    User.get(session_info)
  end

end # Authentication

Having integrated merb_auth_password_slice as per the README, I can successfully login as redirect_after_login is being triggered, although session.authenticated? returns false.

Just trying the basic auth strategy for now (password form), can't seem to get it working, any ideas?

My init file:

require 'dm-validations'

dependencies "merb-more", "merb_helpers", "merb-slices", "merb_auth_password_slice"


Merb::BootLoader.before_app_loads do
  DataMapper.setup(:default, "sqlite3://config/dev.db")
end

Merb::BootLoader.after_app_loads do
    # have already done this
    # raise "You must specify a valid openid in Merb.root/config/open_id to use this example app" unless File.exists?(Merb.root / "config" / "open_id")
    # # DataMapper.auto_migrate!
    # User.create(:login => "admin", 
    #             :password => "password", :password_confirmation => "password", 
    #             :email => "[email protected]", 
    #             :identity_url => File.read(Merb.root / "config" / "open_id"))
end

Merb::Config.use do |c|
  c[:session_secret_key]  = 'my key'
  c[:session_store] = 'cookie'
end

Setup.rb

class Authentication

  def store_user(user)
    return nil unless user
    user.id
  end

  def fetch_user(session_info)
    User.get(session_info)
  end

end # Authentication

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反目相谮 2024-07-13 21:23:32
  # before(nil, :only => [:update, :destroy]) { session.abandon! }

这是切片会话控制器的罪魁祸首

  # before(nil, :only => [:update, :destroy]) { session.abandon! }

This is the culprit in the slice's session controller

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文