私のしたことはわかりませんが、サインインしたユーザーはnew_user_session_pathとnew_user_registration_pathにアクセスできます。通常は、ユーザがこれらのパスにアクセスすることを許可されるべきではありません。違いがあれば私はcancanを使っています。私は新しいレールアプリケーションを作成し、ルート経由でコピーし、登録とセッションコントローラを拡張し、問題を再現することはできません。レール、devise、cancanを使用すると、サインインしたユーザーはサインインとサインアップのパスにアクセスできます
誰かがDeviseでリダイレクトが行われる方向に私を指すことさえできたら、私はそれを感謝します。初期化子/ devise.rb設定ファイルで
、唯一の行は、デフォルトのファイルに追加されます。config.scoped_views = true
が、私は任意の他の有用な情報を提供できるかどうか私に教えてください。 私が考案(1.5.3)、カンカン(1.6.7)、とRails(3.1.1)
routesファイル使用しています:
MyApp::Application.routes.draw do
devise_for :users, :controllers => { :sessions => "sessions", :registrations => "registrations" }, :skip => [ :sessions, :registations ] do
get '/signin' => 'sessions#new', :as => :new_user_session
post '/signin' => 'sessions#create', :as => :user_session
delete '/signout' => 'sessions#destroy', :as => :destroy_user_session
get '/signup' => 'registrations#new', :as => :new_user_registration
post '/users' => 'registrations#create', :as => :user_registration
get '/users/cancel' => 'registrations#cancel', :as => :cancel_user_registration
get '/settings' => 'registrations#edit', :as => :edit_user_registration
put '/account' => 'registrations#update'
delete '/users' => 'registrations#destroy'
end
resources :users
match '/contact', :to => 'pages#contact'
root :to => 'pages#contact'
end
拡張工夫登録コントローラー
class RegistrationsController < Devise::RegistrationsController
# POST /resource
def create
build_resource
resource.company = Company.find_by_code(params[:company_code])
resource.role = Role.find_by_name("Basic")
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :inactive_signed_up, :reason => inactive_reason(resource) if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
respond_with resource
end
end
end
を
拡張デビーズセッションコントローラ:
class SessionsController < Devise::SessionsController
layout "sessions"
end
私はコントローラにいくつかのコードを追加できることを認識していますフィルターを使用してログインしているユーザーを確認し、ユーザーをリダイレクトすることができます。しかし、Deviseは機能を提供しているので、私はそれをする必要はありません。私はそうすることによって、おそらくDeviseの設定で、より大きな問題を無視しているかもしれないと恐れています。
ご協力いただきありがとうございます。ありがとうございました!
「Deviseは機能を提供しています」あなたはそれをどのように知っていますか?それはどこに言いますか? – clyfe
私はそれを使い、新鮮なレールアプリを起動し、インストールした人を何人か求めました。あなたがログインした後、Deviseはあなたがサインインしたりサインアップしたりすることはできません。私は問題を再現するために機能を破るように見えることさえできません。 – Retistic