diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e48b785d8..dc59e6ad3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,7 +16,7 @@ class ApplicationController < ActionController::Base end def after_sign_in_path_for(_resource) - if session[:user_return_to] && session[:user_return_to] != login_path + if session[:user_return_to] return session[:user_return_to].to_s end @@ -27,6 +27,14 @@ class ApplicationController < ActionController::Base end end + def after_sign_out_path_for(_resource) + if request.path.match('registrar') + registrar_login_path + elsif request.path.match('admin') + admin_login_path + end + end + def user_for_paper_trail if defined?(current_user) && current_user.present? # Most of the time it's not loaded in correct time because PaperTrail before filter kicks in diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index 13ab2aab7..ba06b2590 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -56,7 +56,7 @@ %li= link_to t(:api_users), admin_api_users_path %ul.nav.navbar-nav.navbar-right - %li= link_to t('log_out', user: current_user), '/logout' + %li= link_to t('log_out', user: current_user), '/admin/logout' / /.nav-collapse .container diff --git a/app/views/layouts/registrar.haml b/app/views/layouts/registrar.haml index 2ce3e57b2..62bc6adfa 100644 --- a/app/views/layouts/registrar.haml +++ b/app/views/layouts/registrar.haml @@ -31,7 +31,7 @@ - if can? :show, Invoice %li= link_to t('invoices'), registrar_invoices_path %ul.nav.navbar-nav.navbar-right - %li= link_to t('log_out', user: current_user), '/logout' + %li= link_to t('log_out', user: current_user), '/registrar/logout' / /.nav-collapse .container diff --git a/config/routes.rb b/config/routes.rb index cc48a3e07..e4f28e7d7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -68,6 +68,7 @@ Rails.application.routes.draw do devise_scope :user do get 'login' => 'sessions#login' post 'sessions' => 'sessions#create' + get 'logout' => '/devise/sessions#destroy' end root 'domains#index' @@ -79,6 +80,7 @@ Rails.application.routes.draw do devise_scope :user do get 'login' => 'sessions#login' post 'sessions' => 'sessions#create' + get 'logout' => '/devise/sessions#destroy' end # authenticated :user do @@ -90,10 +92,6 @@ Rails.application.routes.draw do devise_for :users - devise_scope :user do - get 'logout' => 'devise/sessions#destroy' - end - # authenticated :user do # root to: 'admin/domains#index', as: :authenticated_root # end