默认情况下,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
方法返回。以下是Google的一个示例。
class ConfirmationsController < Devise::ConfirmationsController
...
protected
def after_confirmation_path_for(resource_name, resource)
...
'https://www.google.com' # assuming you're redirecting to Google
end
end