Refactor sessions

This commit is contained in:
Martin Lensment 2015-03-20 16:39:32 +02:00
parent e2507f8661
commit 744f29c674
18 changed files with 126 additions and 16 deletions

View file

@ -20,3 +20,10 @@
.nowrap
white-space: nowrap
.form-signin
max-width: 330px
padding: 15px
margin: 0 auto
input
margin-bottom: 10px

View file

@ -0,0 +1,10 @@
class Admin::SessionsController < SessionsController
layout 'login'
def create
super
end
def login
end
end

View file

@ -17,9 +17,14 @@ class ApplicationController < ActionController::Base
def after_sign_in_path_for(_resource)
if session[:user_return_to] && session[:user_return_to] != login_path
return session[:user_return_to].to_s
return session[:user_return_to].to_s
end
if request.path.match('registrar')
registrar_invoices_path
elsif request.path.match('admin')
admin_dashboard_path
end
admin_dashboard_path
end
def user_for_paper_trail

View file

@ -0,0 +1,7 @@
class Registrar::InvoicesController < RegistrarController
load_and_authorize_resource
def index
end
end

View file

@ -0,0 +1,7 @@
class Registrar::SessionsController < SessionsController
layout 'registrar'
def login
end
end

View file

@ -0,0 +1,4 @@
class RegistrarController < ApplicationController
before_action :authenticate_user!
layout 'registrar'
end

View file

@ -14,8 +14,4 @@ class SessionsController < Devise::SessionsController
sign_in_and_redirect @user, event: :authentication
# end
end
def login
render 'layouts/login', layout: false
end
end

View file

@ -40,6 +40,7 @@ class Ability
def user
can :show, :dashboard
can :manage, Invoice
end
def customer_service

3
app/models/invoice.rb Normal file
View file

@ -0,0 +1,3 @@
class Invoice < ActiveRecord::Base
end

View file

@ -0,0 +1,6 @@
.form-signin
/ TODO: Refactor this when ID card login is done
= button_to 'ID card (user1)', 'sessions',
class: 'btn btn-lg btn-primary btn-block', name: 'user1'
= button_to 'ID card (user2)', 'sessions',
class: 'btn btn-lg btn-primary btn-block', name: 'user2'

View file

@ -0,0 +1,27 @@
!!!
%html{:lang => I18n.locale.to_s}
%head
%meta{:charset => "utf-8"}/
%meta{:content => "IE=edge", "http-equiv" => "X-UA-Compatible"}/
%meta{:content => "width=device-width, initial-scale=1", :name => "viewport"}/
%meta{:content => "EIS Registrar portal", :name => "description"}/
%meta{:content => "Gitlab Ltd", :name => "author"}/
= csrf_meta_tags
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= stylesheet_link_tag 'login', media: 'all', 'data-turbolinks-track' => true
%link{:href => "../../favicon.ico", :rel => "icon"}/
%title EIS Registrar - Log In
%body{:style => env_style}
.container
.form-signin
- display = (flash.empty?) ? 'none' : 'block'
#flash{style: "display: #{display};"}
- type = (flash[:notice]) ? 'bg-success' : 'bg-danger'
.alert{class: type}= flash[:notice] || flash[:alert]
%h2.form-signin-heading.text-center Eesti Interneti SA
%hr
/ TODO: Refactor this when ID card login is done
= button_to 'ID card (user1)', 'sessions',
class: 'btn btn-lg btn-primary btn-block', name: 'user1'
= button_to 'ID card (user2)', 'sessions',
class: 'btn btn-lg btn-primary btn-block', name: 'user2'

View file

@ -25,8 +25,9 @@
- if unstable_env.present?
.text-center
%small{style: 'color: #0074B3;'}= unstable_env
%ul.nav.navbar-nav.navbar-right
%li= link_to t('log_out', user: current_user), '/logout'
- if current_user
%ul.nav.navbar-nav.navbar-right
%li= link_to t('log_out', user: current_user), '/logout'
/ /.nav-collapse
.container

View file

@ -0,0 +1 @@
invoices

View file

@ -0,0 +1,6 @@
.form-signin
/ TODO: Refactor this when ID card login is done
= button_to 'ID card (user1)', 'sessions',
class: 'btn btn-lg btn-primary btn-block', name: 'user1'
= button_to 'ID card (user2)', 'sessions',
class: 'btn btn-lg btn-primary btn-block', name: 'user2'