2017-10-24 6 views
1

의 프로세스를 거쳐을 제거하고 간단한 bcrypt + cancancan 인증 시스템을 배포했습니다.ActiveAdmin이 작동하지 않음

이제 Devise과 연결된 웹 응용 프로그램의 관리자 부분에 대한 해결책으로 ActiveAdmin도 사용하고 있습니다. 모든 것이 웹 응용 프로그램의 해당 부분에서 깨졌습니다.

나는 우리 자신의 인증 방법을 추가하는 데 해결 된 여러 가지 시도를했지만 라우트에 대한 해결책을 찾지 못했습니다.

관리자 사용자 인 AdminUser 모델이 있습니다. 나는 암호로 일반 사용자가 암호를 사용하도록 "변환"을했으나 (bcrypt로 전환 한 후에) ActiveAdmin으로 무엇을 해야할지 완전히 잃어 버렸습니다.

+0

이것은 광범위한 질문이며 광범위한 대답을 게시했습니다. 정확한 오류가 무엇인지 구체적으로 밝히면보다 정확한 도움을 드릴 수 있습니다. –

답변

3

config/initializers/active_admin.rb에서 다시 구성해야 할 몇 가지 항목이 있습니다.

당신은 인증 방법을 정의 할 필요가 있습니다

# 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 

는 위의 영향을 미치는 활성 관리자 초기화에 두 가지이다 : 당신은 또한 current_user 방법을 설정해야 할 수도 있습니다

# 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 

을 로그인 및 인증. 나는 전체를 살펴보고 사용자 인증 및 권한 부여와 관련된 다른 모든 구성을 살펴볼 것을 권한다. 이니셜 라이저는 주석으로 문서화되어 있으며 Active Admin homepage에 많은 설명서가 있습니다. 활성 관리자가 인증 및 권한 부여에 사용하는 다른 방법 중 일부를 대체해야 할 수도 있습니다.

마지막으로 CanCanCan Ability 클래스가 현재 사용자에게 액세스 할 수 있는지 확인하십시오. 컨트롤러가 올바른 사용자를 전달하지 않으면 액세스가 차단됩니다.

+0

감사합니다, Tom! –