mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Login using api user
This commit is contained in:
parent
99850c3acb
commit
f34bca591e
3 changed files with 19 additions and 1 deletions
|
@ -1,6 +1,15 @@
|
||||||
class Registrar::SessionsController < SessionsController
|
class Registrar::SessionsController < SessionsController
|
||||||
layout 'registrar'
|
layout 'registrar'
|
||||||
|
|
||||||
|
def create
|
||||||
|
@user = ApiUser.first if params[:user1]
|
||||||
|
|
||||||
|
return redirect_to :back, alert: 'No user' if @user.blank?
|
||||||
|
|
||||||
|
flash[:notice] = I18n.t('welcome')
|
||||||
|
sign_in_and_redirect @user, event: :authentication
|
||||||
|
end
|
||||||
|
|
||||||
def login
|
def login
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,7 @@ class Ability
|
||||||
@user.roles.each { |role| send(role) } if @user.roles
|
@user.roles.each { |role| send(role) } if @user.roles
|
||||||
when 'ApiUser'
|
when 'ApiUser'
|
||||||
epp
|
epp
|
||||||
|
registrar
|
||||||
end
|
end
|
||||||
|
|
||||||
can :show, :dashboard
|
can :show, :dashboard
|
||||||
|
@ -38,6 +39,10 @@ class Ability
|
||||||
end
|
end
|
||||||
# rubocop: enabled Metrics/CyclomaticComplexity
|
# rubocop: enabled Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
|
def registrar
|
||||||
|
can :manage, Invoice
|
||||||
|
end
|
||||||
|
|
||||||
def user
|
def user
|
||||||
can :show, :dashboard
|
can :show, :dashboard
|
||||||
can :manage, Invoice
|
can :manage, Invoice
|
||||||
|
|
|
@ -25,7 +25,11 @@
|
||||||
- if unstable_env.present?
|
- if unstable_env.present?
|
||||||
.text-center
|
.text-center
|
||||||
%small{style: 'color: #0074B3;'}= unstable_env
|
%small{style: 'color: #0074B3;'}= unstable_env
|
||||||
- if current_user
|
- if current_user
|
||||||
|
.navbar-collapse.collapse
|
||||||
|
%ul.nav.navbar-nav
|
||||||
|
- if can? :show, Invoice
|
||||||
|
%li= link_to t('invoices'), registrar_invoices_path
|
||||||
%ul.nav.navbar-nav.navbar-right
|
%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), '/logout'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue