Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ end
gem 'rails', '~> 5.1'

gem 'pg'
gem 'authlogic', '~> 3'
gem 'devise'
gem 'devise-encryptable'
gem 'jc-validates_timeliness'
gem 'awesome_nested_set'
gem 'will_paginate'
Expand All @@ -18,8 +19,8 @@ gem 'cups'
gem 'simple_form'

# Files Processors
gem 'carrierwave'
gem 'carrierwave_backgrounder'
gem 'carrierwave', '~> 0.11.2'
gem 'carrierwave_backgrounder', '~> 0.4.2'
gem 'mini_magick', '3.8.1'
gem 'rghost' #Could make it happen only with carrierwave
gem 'pdf-reader'
Expand Down
34 changes: 20 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,11 @@ GEM
archive-zip (0.7.0)
io-like (~> 0.3.0)
arel (8.0.0)
authlogic (3.6.1)
activerecord (>= 3.2, < 5.2)
activesupport (>= 3.2, < 5.2)
request_store (~> 1.0)
scrypt (>= 1.2, < 4.0)
awesome_nested_set (3.1.3)
activerecord (>= 4.0.0, < 5.2)
awesome_print (1.8.0)
barby (0.6.5)
bcrypt (3.1.12)
bcrypt_pbkdf (1.0.0)
bugsnag (6.3.0)
builder (3.2.3)
Expand Down Expand Up @@ -116,16 +112,21 @@ GEM
database_cleaner (1.6.2)
declarative (0.0.10)
declarative-option (0.1.0)
devise (4.5.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
devise-encryptable (0.2.0)
devise (>= 2.1.0)
ed25519 (1.2.4)
erubi (1.7.0)
eventmachine (1.2.5)
execjs (2.7.0)
faraday (0.13.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
get_process_mem (0.2.1)
globalid (0.4.1)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -206,6 +207,7 @@ GEM
nio4r (2.1.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
orm_adapter (0.5.0)
os (0.9.6)
paper_trail (8.1.1)
activerecord (>= 4.2, < 5.2)
Expand Down Expand Up @@ -270,6 +272,9 @@ GEM
declarative-option (< 0.2.0)
uber (< 0.2.0)
request_store (1.3.2)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
retriable (3.1.1)
rghost (0.9.6)
rqrcode (0.10.1)
Expand All @@ -288,8 +293,6 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
scrypt (3.0.5)
ffi-compiler (>= 1.0, < 2.0)
selenium-webdriver (2.53.4)
childprocess (~> 0.5)
rubyzip (~> 1.0)
Expand Down Expand Up @@ -346,6 +349,8 @@ GEM
unicorn-worker-killer (0.4.4)
get_process_mem (~> 0)
unicorn (>= 4, < 6)
warden (1.2.7)
rack (>= 1.0)
websocket (1.2.5)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
Expand All @@ -361,7 +366,6 @@ PLATFORMS

DEPENDENCIES
RedCloth
authlogic (~> 3)
awesome_nested_set
awesome_print
barby
Expand All @@ -374,13 +378,15 @@ DEPENDENCIES
capistrano-rails
capybara
capybara-screenshot
carrierwave
carrierwave_backgrounder
carrierwave (~> 0.11.2)
carrierwave_backgrounder (~> 0.4.2)
chromedriver-helper
chunky_png
coffee-rails (~> 4.2)
cups
database_cleaner
devise
devise-encryptable
ed25519
google_drive
interactive_editor
Expand Down Expand Up @@ -415,4 +421,4 @@ DEPENDENCIES
will_paginate

BUNDLED WITH
1.16.1
1.16.4
56 changes: 39 additions & 17 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base

protect_from_forgery with: :null_session, unless: :trusted_sites

before_action :set_js_format_in_iframe_request, :set_paper_trail_whodunnit
before_action :set_js_format_in_iframe_request, :set_paper_trail_whodunnit, :assign_currents
before_bugsnag_notify :add_user_info_to_bugsnag
after_action -> { expires_now if current_user || current_customer }

Expand Down Expand Up @@ -51,22 +51,6 @@ def add_user_info_to_bugsnag(notif)
end
end

def current_customer_session
@current_customer_session ||= CustomerSession.find
end

def current_customer
@current_customer ||= current_customer_session && current_customer_session.record
end

def current_user_session
@current_user_session ||= UserSession.find
end

def current_user
@current_user ||= current_user_session && current_user_session.record
end

def user_for_paper_trail
current_user.try(:id)
end
Expand Down Expand Up @@ -231,4 +215,42 @@ def trusted_sites
return true if request.headers[custom_header] == site
end
end

def assign_currents
Current.user = current_user
Current.customer = current_customer
end

# Devise SignIn callback
def after_sign_in_path_for(resource_or_scope)
session[:has_an_open_shift] = current_user.has_stale_shift?
current_user
if @user_session.record.has_stale_shift?
[
edit_shift_url(@user_session.record.stale_shift),
notice: t('view.shifts.edit_stale')
]
else
[prints_url, notice: t('view.user_sessions.correctly_created')]
end

end

# Devise SignOut callback
def after_sign_out_path_for(resource_or_scope)
if resource_or_scope == :user
new_user_session_path
elsif resource_or_scope == :admin
new_admin_session_path
else
root_path
end
if params[:close_shift]
if params[:as_operator]
current_user.last_open_shift_as_operator!
end

current_user_session.close_shift!
end
end
end
30 changes: 30 additions & 0 deletions app/controllers/customers/confirmations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

class Customers::ConfirmationsController < Devise::ConfirmationsController
# GET /resource/confirmation/new
# def new
# super
# end

# POST /resource/confirmation
# def create
# super
# end

# GET /resource/confirmation?confirmation_token=abcdef
# def show
# super
# end

# protected

# The path used after resending confirmation instructions.
# def after_resending_confirmation_instructions_path_for(resource_name)
# super(resource_name)
# end

# The path used after confirmation.
# def after_confirmation_path_for(resource_name, resource)
# super(resource_name, resource)
# end
end
30 changes: 30 additions & 0 deletions app/controllers/customers/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

class Customers::OmniauthCallbacksController < Devise::OmniauthCallbacksController
# You should configure your model like this:
# devise :omniauthable, omniauth_providers: [:twitter]

# You should also create an action method in this controller like this:
# def twitter
# end

# More info at:
# https://github.com/plataformatec/devise#omniauth

# GET|POST /resource/auth/twitter
# def passthru
# super
# end

# GET|POST /users/auth/twitter/callback
# def failure
# super
# end

# protected

# The path used when OmniAuth fails
# def after_omniauth_failure_path_for(scope)
# super(scope)
# end
end
34 changes: 34 additions & 0 deletions app/controllers/customers/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

class Customers::PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new
# super
# end

# POST /resource/password
# def create
# super
# end

# GET /resource/password/edit?reset_password_token=abcdef
# def edit
# super
# end

# PUT /resource/password
# def update
# super
# end

# protected

# def after_resetting_password_path_for(resource)
# super(resource)
# end

# The path used after sending reset password instructions
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
end
62 changes: 62 additions & 0 deletions app/controllers/customers/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# frozen_string_literal: true

class Customers::RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]

# GET /resource/sign_up
# def new
# super
# end

# POST /resource
# def create
# super
# end

# GET /resource/edit
# def edit
# super
# end

# PUT /resource
# def update
# super
# end

# DELETE /resource
# def destroy
# super
# end

# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end

# protected

# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_up_params
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
# end

# If you have extra params to permit, append them to the sanitizer.
# def configure_account_update_params
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
# end

# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end

# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end
27 changes: 27 additions & 0 deletions app/controllers/customers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

class Customers::SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]

# GET /resource/sign_in
# def new
# super
# end

# POST /resource/sign_in
# def create
# super
# end

# DELETE /resource/sign_out
# def destroy
# super
# end

# protected

# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_in_params
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
# end
end
Loading