mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Refactored to use abilites for login
This commit is contained in:
parent
f0b46469c8
commit
61e2ea9823
3 changed files with 25 additions and 12 deletions
|
@ -10,10 +10,12 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_sign_in_path_for(resource)
|
def after_sign_in_path_for(resource)
|
||||||
if REGISTRY_ENV == :admin && resource.admin?
|
return session[:user_return_to].to_s if session[:user_return_to]
|
||||||
(session[:user_return_to].nil?) ? admin_root_path : session[:user_return_to].to_s
|
|
||||||
|
if resource.admin? && can?(:create, :admin_session)
|
||||||
|
admin_root_path
|
||||||
else
|
else
|
||||||
(session[:user_return_to].nil?) ? client_root_path : session[:user_return_to].to_s
|
client_root_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,14 +7,22 @@ class Ability
|
||||||
|
|
||||||
user ||= User.new
|
user ||= User.new
|
||||||
|
|
||||||
# public user abilites
|
if Rails.env.production?
|
||||||
can :create, :session
|
case REGISTRY_ENV
|
||||||
|
when :client
|
||||||
if REGISTRY_ENV == :admin
|
can :create, :session
|
||||||
|
admin = false
|
||||||
|
when :admin
|
||||||
|
can :create, :admin_session
|
||||||
|
admin = user.admin?
|
||||||
|
end
|
||||||
|
else
|
||||||
|
can :create, :session
|
||||||
can :create, :admin_session
|
can :create, :admin_session
|
||||||
|
admin = user.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
if (Rails.env.production? ? REGISTRY_ENV == :admin && user.admin? : user.admin?)
|
if admin
|
||||||
can :manage, Domain
|
can :manage, Domain
|
||||||
can :switch, :registrar
|
can :switch, :registrar
|
||||||
can :crud, DomainTransfer
|
can :crud, DomainTransfer
|
||||||
|
|
|
@ -21,8 +21,11 @@
|
||||||
%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
|
||||||
- if Rails.env.development? || (can? :create, :admin_session)
|
- if can? :create, :admin_session
|
||||||
= button_to 'ID card (gitlab)', 'sessions', class: 'btn btn-lg btn-primary btn-block', name: 'gitlab'
|
= button_to 'ID card (gitlab)', 'sessions',
|
||||||
|
class: 'btn btn-lg btn-primary btn-block', name: 'gitlab'
|
||||||
- if can? :create, :session
|
- if can? :create, :session
|
||||||
= button_to 'ID card (zone)', 'sessions', class: 'btn btn-lg btn-primary btn-block', name: 'zone'
|
= button_to 'ID card (zone)', 'sessions',
|
||||||
= button_to 'ID card (elkdata)', 'sessions', class: 'btn btn-lg btn-primary btn-block', name: 'elkdata'
|
class: 'btn btn-lg btn-primary btn-block', name: 'zone'
|
||||||
|
= button_to 'ID card (elkdata)', 'sessions',
|
||||||
|
class: 'btn btn-lg btn-primary btn-block', name: 'elkdata'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue