This commit is contained in:
benji 2015-01-09 13:12:19 +01:00
parent 7684f54120
commit 466b479ffd
4 changed files with 7 additions and 11 deletions

View file

@ -0,0 +1,5 @@
class UserHomepageConstraint < Struct.new(:role)
def matches?(request)
role == request.env['warden'].user.koelkast?
end
end

View file

@ -1,8 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__) APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot' require_relative '../config/boot'
require 'rails/commands' require 'rails/commands'

View file

@ -1,8 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require_relative '../config/boot' require_relative '../config/boot'
require 'rake' require 'rake'
Rake.application.run Rake.application.run

View file

@ -6,9 +6,8 @@ Rails.application.routes.draw do
root to: 'devise/sessions#new' root to: 'devise/sessions#new'
end end
authenticated :user do authenticated :user do
root to: 'devise/sessions#new', constraints: lambda { |req| req.env['warden'].user.nil? }, as: 'unauth_root' root to: 'orders#overview', constraints: UserHomepageConstraint.new(true), as: 'koelkast_root'
root to: 'orders#overview', constraints: lambda { |req| req.env['warden'].user.koelkast? }, as: 'koelkast_root' root to: 'users#show', constraints: UserHomepageConstraint.new(false), as: 'user_root'
root to: 'users#show', constraints: lambda { |req| !req.env['warden'].user.koelkast? }, as: 'user_root'
end end
end end