簡體   English   中英

ActiveAdmin沒有設計就無法工作

[英]ActiveAdmin Not Working Without Devise

所以我們剛剛完成了刪除 Devise的過程,並推出了簡單的bcrypt + cancancan auth系統。

現在我們也使用ActiveAdmin作為Web應用程序管理部分的解決方案,該應用程序與Devise綁定。 在網絡應用程序的那一部分,一切都被打破了:)

我嘗試了幾個不同的東西,解決了添加我們自己的身份驗證方法,但我找不到路由的解決方案,還有什么需要。

我們有一個AdminUser模型應該是管理員用戶。 我做了“轉換”它以使用普通用戶使用密碼的列(在我們切換到bcrypt之后),但我完全失去了如何使用ActiveAdmin。

config/initializers/active_admin.rb可能需要重新配置幾個項目。

您可能需要定義身份驗證方法:

# config/initializers/active_admin.rb

# == User Authentication
#
# Active Admin will automatically call an authentication
# method in a before filter of all controller actions to
# ensure that there is a currently logged in admin user.
#
# This setting changes the method which Active Admin calls
# within the application controller.
config.authentication_method = :authenticate_active_admin_user!

# app/controllers/application_controller.rb
def authenticat_active_admin_user!
  # Something that returns true if the current user has access to active admin
end

您可能還需要設置current_user方法:

# config/initializers/active_admin.rb

# == Current User
#
# Active Admin will associate actions with the current
# user performing them.
#
# This setting changes the method which Active Admin calls
# (within the application controller) to return the currently logged in user.
config.current_user_method = :current_user

# app/controllers/application_controller.rb
def current_user
  # returns the current logged in user.  Devise provides this automatically. You will need to replace that functionality.
end

以上只是Active Admin初始化程序中影響登錄和身份驗證的兩件事。 我建議通過整個過程,查看與用戶身份驗證和授權相關的所有其他配置。 初始化程序有很好的文檔和注釋,Active Admin 主頁中有大量文檔。 您可能會發現需要替換主動管理員用於身份驗證和授權的其他一些方法。

最后,確保您的CanCanCan Ability類能夠訪問當前用戶。 如果您的控制器沒有將正確的用戶傳遞給它,那么它將阻止訪問。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM