【发布时间】:2019-07-02 01:46:15
【问题描述】:
默认情况下,Gitlab 在电子邮件确认后将用户重定向到主页。我想改为异地重定向。
我不认为有一个配置选项,所以我问如何破解它。
我找到了confirmations_controller.rb:
# frozen_string_literal: true
class ConfirmationsController < Devise::ConfirmationsController
include AcceptsPendingInvitations
def almost_there
flash[:notice] = nil
render layout: "devise_empty"
end
protected
def after_resending_confirmation_instructions_path_for(resource)
users_almost_there_path
end
def after_confirmation_path_for(resource_name, resource)
accept_pending_invitations
# incoming resource can either be a :user or an :email
if signed_in?(:user)
after_sign_in(resource)
else
Gitlab::AppLogger.info("Email Confirmed: username=#{resource.username} email=#{resource.email} ip=#{request.remote_ip}")
flash[:notice] = flash[:notice] + " Please sign in."
new_session_path(:user, anchor: 'login-pane')
end
end
def after_sign_in(resource)
after_sign_in_path_for(resource)
end
end
如何让它将我重定向到 google.com?
【问题讨论】:
-
只需覆盖代码中
after_confirmation_path_for方法的返回值。 -
您希望新的确认路径是什么?
-
“以前接受的答案不再有效。”新行为是否与原始行为相同? AFAIK Amin 的回答应该仍然有效。有关正在发生的事情的更多信息会有所帮助。
-
你问过作者吗?给他们的代码添加这个功能并提交补丁怎么样?
-
为什么以前接受的答案不再有效?如果答案停止工作,您的问题就会漂移,这意味着您需要提出一个新问题,而不是坚持新的答案。请参阅有关元的这些讨论:“Exit strategies for “chameleon questions””“Etiquette for Russian Doll Questions”“Are questions by default permitted to evolve, and if so, to what extent?”
标签: ruby redirect devise gitlab