mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Refactor sessions
This commit is contained in:
parent
e2507f8661
commit
744f29c674
18 changed files with 126 additions and 16 deletions
|
@ -20,3 +20,10 @@
|
||||||
|
|
||||||
.nowrap
|
.nowrap
|
||||||
white-space: nowrap
|
white-space: nowrap
|
||||||
|
|
||||||
|
.form-signin
|
||||||
|
max-width: 330px
|
||||||
|
padding: 15px
|
||||||
|
margin: 0 auto
|
||||||
|
input
|
||||||
|
margin-bottom: 10px
|
||||||
|
|
10
app/controllers/admin/sessions_controller.rb
Normal file
10
app/controllers/admin/sessions_controller.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
class Admin::SessionsController < SessionsController
|
||||||
|
layout 'login'
|
||||||
|
|
||||||
|
def create
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def login
|
||||||
|
end
|
||||||
|
end
|
|
@ -19,8 +19,13 @@ class ApplicationController < ActionController::Base
|
||||||
if session[:user_return_to] && session[:user_return_to] != login_path
|
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
|
end
|
||||||
|
|
||||||
|
if request.path.match('registrar')
|
||||||
|
registrar_invoices_path
|
||||||
|
elsif request.path.match('admin')
|
||||||
admin_dashboard_path
|
admin_dashboard_path
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def user_for_paper_trail
|
def user_for_paper_trail
|
||||||
if defined?(current_user) && current_user.present?
|
if defined?(current_user) && current_user.present?
|
||||||
|
|
7
app/controllers/registrar/invoices_controller.rb
Normal file
7
app/controllers/registrar/invoices_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class Registrar::InvoicesController < RegistrarController
|
||||||
|
load_and_authorize_resource
|
||||||
|
|
||||||
|
def index
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
7
app/controllers/registrar/sessions_controller.rb
Normal file
7
app/controllers/registrar/sessions_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class Registrar::SessionsController < SessionsController
|
||||||
|
layout 'registrar'
|
||||||
|
|
||||||
|
def login
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
4
app/controllers/registrar_controller.rb
Normal file
4
app/controllers/registrar_controller.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
class RegistrarController < ApplicationController
|
||||||
|
before_action :authenticate_user!
|
||||||
|
layout 'registrar'
|
||||||
|
end
|
|
@ -14,8 +14,4 @@ class SessionsController < Devise::SessionsController
|
||||||
sign_in_and_redirect @user, event: :authentication
|
sign_in_and_redirect @user, event: :authentication
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
def login
|
|
||||||
render 'layouts/login', layout: false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,7 @@ class Ability
|
||||||
|
|
||||||
def user
|
def user
|
||||||
can :show, :dashboard
|
can :show, :dashboard
|
||||||
|
can :manage, Invoice
|
||||||
end
|
end
|
||||||
|
|
||||||
def customer_service
|
def customer_service
|
||||||
|
|
3
app/models/invoice.rb
Normal file
3
app/models/invoice.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
class Invoice < ActiveRecord::Base
|
||||||
|
|
||||||
|
end
|
6
app/views/admin/sessions/login.haml
Normal file
6
app/views/admin/sessions/login.haml
Normal 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'
|
27
app/views/layouts/login_registrar.haml
Normal file
27
app/views/layouts/login_registrar.haml
Normal 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'
|
|
@ -25,6 +25,7 @@
|
||||||
- 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
|
||||||
%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'
|
||||||
|
|
||||||
|
|
1
app/views/registrar/invoices/index.haml
Normal file
1
app/views/registrar/invoices/index.haml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
invoices
|
6
app/views/registrar/sessions/login.haml
Normal file
6
app/views/registrar/sessions/login.haml
Normal 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'
|
|
@ -65,21 +65,38 @@ Rails.application.routes.draw do
|
||||||
resources :epp_logs
|
resources :epp_logs
|
||||||
resources :repp_logs
|
resources :repp_logs
|
||||||
|
|
||||||
|
devise_scope :user do
|
||||||
|
get 'login' => 'sessions#login'
|
||||||
|
post 'sessions' => 'sessions#create'
|
||||||
|
end
|
||||||
|
|
||||||
|
root 'domains#index'
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace(:registrar) do
|
||||||
|
resources :invoices
|
||||||
|
|
||||||
|
devise_scope :user do
|
||||||
|
get 'login' => 'sessions#login'
|
||||||
|
post 'sessions' => 'sessions#create'
|
||||||
|
end
|
||||||
|
|
||||||
|
# authenticated :user do
|
||||||
|
# root to: 'domains#index', as: :authenticated_root
|
||||||
|
# end
|
||||||
|
|
||||||
root 'domains#index'
|
root 'domains#index'
|
||||||
end
|
end
|
||||||
|
|
||||||
devise_for :users
|
devise_for :users
|
||||||
|
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
resources :sessions
|
|
||||||
|
|
||||||
get 'logout' => 'devise/sessions#destroy'
|
get 'logout' => 'devise/sessions#destroy'
|
||||||
get 'login' => 'sessions#login'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
authenticated :user do
|
# authenticated :user do
|
||||||
root to: 'admin/domains#index', as: :authenticated_root
|
# root to: 'admin/domains#index', as: :authenticated_root
|
||||||
end
|
# end
|
||||||
|
|
||||||
root to: redirect('login')
|
root to: redirect('login')
|
||||||
|
|
||||||
|
|
7
db/migrate/20150320132023_create_invoices.rb
Normal file
7
db/migrate/20150320132023_create_invoices.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class CreateInvoices < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :invoices do |t|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150303151224) do
|
ActiveRecord::Schema.define(version: 20150320132023) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -226,6 +226,11 @@ ActiveRecord::Schema.define(version: 20150303151224) do
|
||||||
add_index "epp_sessions", ["session_id"], name: "index_epp_sessions_on_session_id", unique: true, using: :btree
|
add_index "epp_sessions", ["session_id"], name: "index_epp_sessions_on_session_id", unique: true, using: :btree
|
||||||
add_index "epp_sessions", ["updated_at"], name: "index_epp_sessions_on_updated_at", using: :btree
|
add_index "epp_sessions", ["updated_at"], name: "index_epp_sessions_on_updated_at", using: :btree
|
||||||
|
|
||||||
|
create_table "invoices", force: :cascade do |t|
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "keyrelays", force: :cascade do |t|
|
create_table "keyrelays", force: :cascade do |t|
|
||||||
t.integer "domain_id"
|
t.integer "domain_id"
|
||||||
t.datetime "pa_date"
|
t.datetime "pa_date"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue