Fix login paths

This commit is contained in:
Martin Lensment 2015-03-24 12:04:58 +02:00
parent f791631ba1
commit a615827b8e
4 changed files with 17 additions and 11 deletions

View file

@ -17,8 +17,14 @@ class ApplicationController < ActionController::Base
def after_sign_in_path_for(_resource) def after_sign_in_path_for(_resource)
rt = session[:user_return_to].to_s.presence rt = session[:user_return_to].to_s.presence
return session[:user_return_to].to_s if rt && rt != admin_login_path login_paths = [admin_login_path, registrar_login_path]
admin_dashboard_path return rt if rt && !login_paths.include?(rt)
if request.path.match('registrar')
registrar_root_path
elsif request.path.match('admin')
admin_root_path
end
end end
def after_sign_out_path_for(_resource) def after_sign_out_path_for(_resource)

View file

@ -21,7 +21,7 @@
%h2.form-signin-heading.text-center Eesti Interneti SA %h2.form-signin-heading.text-center Eesti Interneti SA
%hr %hr
/ TODO: Refactor this when ID card login is done / TODO: Refactor this when ID card login is done
= button_to 'ID card (user1)', 'sessions', = button_to 'ID card (user1)', admin_sessions_path,
class: 'btn btn-lg btn-primary btn-block', name: 'user1' class: 'btn btn-lg btn-primary btn-block', name: 'user1'
= button_to 'ID card (user2)', 'sessions', = button_to 'ID card (user2)', admin_sessions_path,
class: 'btn btn-lg btn-primary btn-block', name: 'user2' class: 'btn btn-lg btn-primary btn-block', name: 'user2'

View file

@ -20,7 +20,7 @@
%span.icon-bar %span.icon-bar
%span.icon-bar %span.icon-bar
%span.icon-bar %span.icon-bar
= link_to registrar_invoices_path, class: 'navbar-brand' do = link_to registrar_root_path, class: 'navbar-brand' do
EIS Registrar EIS Registrar
- if unstable_env.present? - if unstable_env.present?
.text-center .text-center

View file

@ -75,7 +75,7 @@ Rails.application.routes.draw do
get 'logout' => '/devise/sessions#destroy' get 'logout' => '/devise/sessions#destroy'
end end
root 'domains#index' root 'dashboards#show'
end end
namespace(:registrar) do namespace(:registrar) do
@ -96,16 +96,16 @@ Rails.application.routes.draw do
# root to: 'domains#index', as: :authenticated_root # root to: 'domains#index', as: :authenticated_root
# end # end
root 'domains#index' root 'invoices#index'
end end
devise_for :users devise_for :users
# authenticated :user do devise_scope :user do
# root to: 'admin/domains#index', as: :authenticated_root get 'login' => 'admin/sessions#login'
# end end
root to: redirect('admin/login') root to: redirect('login')
# The priority is based upon order of creation: first created -> highest priority. # The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes". # See how all your routes lay out with "rake routes".