簡體   English   中英

設計無效的忘記密碼URL

[英]Devise invalid forgot password URL

我有模型用戶。 和型號

CaBase <用戶LaUser <用戶

兩種型號都具有:

devise :database_authenticatable, :recoverable, :rememberable,
     :trackable, :validatable

LaUser-有權訪問管理區域的用戶。 CaBase-僅可訪問前端的用戶。

當我在CaBase登錄表單上單擊“忘記密碼”時,它將通過以下鏈接向我發送郵件:

site_name/admin/password/edit?reset_password_token=gtwSWQK8HH2-6p4CHp

但我需要它

site_name/password/edit?reset_password_token=gtwSWQK8HH2-6p4CHp

我在ApplicationController中也有動作

def after_sign_in_path_for(resource)
    if resource.is_a?(LaUser)
      admin_root_path
    else
      dashboard_index_path
    end
  end

  def after_sending_reset_password_instructions_path_for(resource)
    if resource.is_a?(LaUser)
      admin_root_path
    else
      dashboard_index_path
    end
  end

我該怎么辦?

UPD1:

get 'dashboard/index'

  ActiveAdmin.routes(self)
  devise_for :la_users, ActiveAdmin::Devise.config
  devise_for :ca_base, path: '', path_names: {sign_in: 'login'}
  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  root 'welcome#index'

  resource :ca_administrators, only: [:new, :create]

問題是我沒有檢查哪個角色具有當前用戶。

來自Devise Mailer的代碼。

 if record.is_a?(LaUser)
      controller = 'active_admin/devise/passwords'
    else
      controller = 'devise/passwords'
    end

    edit_password_url = url_for(
        controller: controller,
        action: :edit,
        reset_password_token: token
    )

暫無
暫無

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

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