简体   繁体   English

设计无效的忘记密码URL

[英]Devise invalid forgot password URL

I have model User. 我有模型用户。 And models 和型号

CaBase < User LaUser < User CaBase <用户LaUser <用户

Both models has: 两种型号都具有:

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

LaUser- Users that have access to Admin area. LaUser-有权访问管理区域的用户。 CaBase - Users that has access only for front-end. CaBase-仅可访问前端的用户。

When I click on forgot password on CaBase login form, it mails me with link like: 当我在CaBase登录表单上单击“忘记密码”时,它将通过以下链接向我发送邮件:

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

But I need it to 但我需要它

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

Also I have actions in ApplicationController 我在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

What can I do with it? 我该怎么办?

UPD1: 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]

Problem was in that I don't checked which role have current user. 问题是我没有检查哪个角色具有当前用户。

Code from Devise Mailer. 来自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