<3 relix
This commit is contained in:
parent
7684f54120
commit
466b479ffd
4 changed files with 7 additions and 11 deletions
5
app/constraints/user_homepage_constraint.rb
Normal file
5
app/constraints/user_homepage_constraint.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class UserHomepageConstraint < Struct.new(:role)
|
||||||
|
def matches?(request)
|
||||||
|
role == request.env['warden'].user.koelkast?
|
||||||
|
end
|
||||||
|
end
|
|
@ -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'
|
||||||
|
|
4
bin/rake
4
bin/rake
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue