Login using api user

This commit is contained in:
Martin Lensment 2015-03-20 18:11:37 +02:00
parent 99850c3acb
commit f34bca591e
3 changed files with 19 additions and 1 deletions

View file

@ -1,6 +1,15 @@
class Registrar::SessionsController < SessionsController
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
end

View file

@ -11,6 +11,7 @@ class Ability
@user.roles.each { |role| send(role) } if @user.roles
when 'ApiUser'
epp
registrar
end
can :show, :dashboard
@ -38,6 +39,10 @@ class Ability
end
# rubocop: enabled Metrics/CyclomaticComplexity
def registrar
can :manage, Invoice
end
def user
can :show, :dashboard
can :manage, Invoice

View file

@ -25,7 +25,11 @@
- if unstable_env.present?
.text-center
%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
%li= link_to t('log_out', user: current_user), '/logout'