trusty-cms 3.8.0 → 3.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +100 -92
  3. data/app/assets/images/admin/default_forgot_password.svg +1 -0
  4. data/app/assets/images/admin/default_reset_password.svg +1 -0
  5. data/app/assets/images/admin/default_safe_login.svg +1 -0
  6. data/app/assets/javascripts/admin.js +0 -1
  7. data/app/assets/javascripts/admin/modernizr.js +3 -409
  8. data/app/assets/stylesheets/admin/partials/_forms.scss +39 -0
  9. data/app/assets/stylesheets/admin/partials/_layout.scss +8 -0
  10. data/app/assets/stylesheets/admin/partials/_validations.scss +6 -13
  11. data/app/controllers/admin/assets_controller.rb +7 -0
  12. data/app/controllers/admin/preferences_controller.rb +1 -1
  13. data/app/controllers/admin/resource_controller.rb +6 -0
  14. data/app/controllers/admin/users_controller.rb +3 -2
  15. data/app/controllers/application_controller.rb +5 -7
  16. data/app/controllers/site_controller.rb +2 -1
  17. data/app/controllers/social_mailer_controller.rb +2 -1
  18. data/app/models/legacy_user.rb +6 -0
  19. data/app/models/user.rb +39 -68
  20. data/app/models/user_action_observer.rb +4 -2
  21. data/app/views/admin/configuration/show.html.haml +2 -7
  22. data/app/views/admin/layouts/_site_chooser.html.haml +1 -1
  23. data/app/views/admin/pages/_node.html.haml +2 -2
  24. data/app/views/admin/preferences/edit.html.haml +9 -14
  25. data/app/views/admin/users/_form.html.haml +8 -15
  26. data/app/views/admin/users/index.html.haml +0 -1
  27. data/app/views/devise/passwords/edit.html.haml +23 -0
  28. data/app/views/devise/passwords/new.html.haml +14 -0
  29. data/app/views/devise/sessions/new.html.haml +25 -0
  30. data/app/views/devise/shared/_links.html.haml +16 -0
  31. data/app/views/layouts/application.html.haml +1 -1
  32. data/config/application.rb +1 -0
  33. data/config/initializers/devise.rb +310 -0
  34. data/config/routes.rb +6 -10
  35. data/db/migrate/20200117141251_create_admin_users.rb +51 -0
  36. data/lib/generators/extension_controller/templates/controller.rb +1 -1
  37. data/lib/login_system.rb +40 -44
  38. data/lib/tasks/upgrade_to_devise.rake +22 -0
  39. data/lib/trusty_cms.rb +1 -1
  40. data/lib/trusty_cms/admin_ui.rb +3 -3
  41. data/lib/trusty_cms/engine.rb +2 -0
  42. data/lib/trusty_cms/setup.rb +0 -1
  43. data/trusty_cms.gemspec +1 -0
  44. data/vendor/extensions/clipped-extension/clipped_extension.rb +0 -2
  45. data/vendor/extensions/multi-site-extension/lib/multi_site/site_chooser_helper.rb +1 -1
  46. data/vendor/extensions/snippets-extension/snippets_extension.rb +0 -2
  47. metadata +27 -8
  48. data/app/assets/javascripts/admin/cookie.js +0 -80
  49. data/app/controllers/admin/password_resets_controller.rb +0 -31
  50. data/app/controllers/admin/welcome_controller.rb +0 -47
  51. data/app/views/admin/password_resets/edit.html.haml +0 -27
  52. data/app/views/admin/password_resets/new.html.haml +0 -12
  53. data/app/views/password_mailer/password_reset.html.haml +0 -8
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  TrustyCms::Application.routes.draw do
2
2
  root to: 'site#show_page'
3
-
3
+ devise_for :users, module: :devise
4
4
  get '/rad_social/mail' => 'social_mailer#social_mail_form', as: :rad_social_mail_form
5
5
  post '/rad_social/mail' => 'social_mailer#create_social_mail', as: :rad_create_social_mail
6
6
  TrustyCms::Application.config.enabled_extensions.each { |ext|
@@ -19,7 +19,6 @@ TrustyCms::Application.routes.draw do
19
19
  resources :snippets do
20
20
  get :remove, on: :member
21
21
  end
22
- resources :password_resets
23
22
  post 'save-table-position' => "pages#save_table_position", as: "save_tables_position"
24
23
 
25
24
  resources :assets do
@@ -28,7 +27,7 @@ TrustyCms::Application.routes.draw do
28
27
  post :regenerate, on: :collection
29
28
  put :refresh, on: :member
30
29
  end
31
- resources :page_attachments, :only => [:new] do
30
+ resources :page_attachments, only: [:new] do
32
31
  get :remove, on: :member
33
32
  end
34
33
  resources :pages do
@@ -38,10 +37,12 @@ TrustyCms::Application.routes.draw do
38
37
  end
39
38
 
40
39
  match 'admin/preview' => 'admin/pages#preview', :as => :preview, :via => [:post, :put]
40
+ get 'admin' => 'admin/pages#index'
41
+
41
42
  namespace :admin do
42
43
  resource :preferences
43
- resource :configuration, :controller => 'configuration'
44
- resources :extensions, :only => :index
44
+ resource :configuration, controller: 'configuration'
45
+ resources :extensions, only: :index
45
46
  resources :page_parts
46
47
  resources :page_fields
47
48
  match '/reference/:type(.:format)' => 'references#show', :as => :reference, :via => :get
@@ -55,12 +56,7 @@ TrustyCms::Application.routes.draw do
55
56
  end
56
57
  end
57
58
 
58
- get 'admin' => 'admin/welcome#index', :as => :admin
59
- get 'admin/welcome' => 'admin/welcome#index', :as => :welcome
60
- match 'admin/login' => 'admin/welcome#login', :as => :login, :via => [:get, :post]
61
- get 'admin/logout' => 'admin/welcome#logout', :as => :logout
62
59
  get 'error/404' => 'site#not_found', :as => :not_found
63
60
  get 'error/500' => 'site#error', :as => :error
64
61
  get '*url' => 'site#show_page'
65
-
66
62
  end
@@ -0,0 +1,51 @@
1
+ class CreateAdminUsers < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table(:admins) do |t|
4
+ ## Database authenticatable
5
+ t.string :email, null: false, default: ""
6
+ t.string :encrypted_password, null: false, default: ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, default: 0, null: false
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+
22
+ ## Confirmable
23
+ t.string :confirmation_token
24
+ t.datetime :confirmed_at
25
+ t.datetime :confirmation_sent_at
26
+ t.string :unconfirmed_email # Only if using reconfirmable
27
+
28
+ ## Lockable
29
+ t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30
+ t.string :unlock_token # Only if unlock strategy is :email or :both
31
+ t.datetime :locked_at
32
+
33
+ # Customization
34
+ t.string :first_name
35
+ t.string :last_name
36
+ t.boolean :admin
37
+ t.boolean :designer
38
+ t.boolean :content_editor
39
+ t.integer :site_id
40
+ t.integer :updated_by_id
41
+ t.text :notes
42
+
43
+ t.timestamps
44
+ end
45
+
46
+ add_index :admins, :email, unique: true
47
+ add_index :admins, :reset_password_token, unique: true
48
+ add_index :admins, :confirmation_token, unique: true
49
+ add_index :admins, :unlock_token, unique: true
50
+ end
51
+ end
@@ -1,7 +1,7 @@
1
1
  class <%= class_name %>Controller < ApplicationController
2
2
  # Remove this line if your controller should only be accessible to users
3
3
  # that are logged in:
4
- no_login_required
4
+ # no_login_required
5
5
  <% for action in actions -%>
6
6
 
7
7
  def <%= action %>
data/lib/login_system.rb CHANGED
@@ -2,58 +2,59 @@ module LoginSystem
2
2
  def self.included(base)
3
3
  base.extend ClassMethods
4
4
  base.class_eval do
5
- prepend_before_action :authenticate
6
- prepend_before_action :authorize
7
- helper_method :current_user
5
+ #prepend_before_action :authenticate
6
+ #prepend_before_action :authorize
7
+ #helper_method :current_user
8
8
  end
9
9
  end
10
10
 
11
11
  protected
12
12
 
13
- def current_user
14
- @current_user ||= (login_from_session || login_from_cookie || login_from_http)
15
- end
13
+ # def current_user
14
+ # end
16
15
 
17
- def current_user=(value=nil)
18
- if value && value.is_a?(User)
19
- @current_user = value
20
- session['user_id'] = value.id
21
- else
22
- @current_user = nil
23
- session['user_id'] = nil
24
- end
25
- @current_user
26
- end
16
+ # def current_user=(value=nil)
17
+ # if value && value.is_a?(User)
18
+ # @current_user = value
19
+ # session['user_id'] = value.id
20
+ # else
21
+ # @current_user = nil
22
+ # session['user_id'] = nil
23
+ # end
24
+ # @current_user
25
+ # end
27
26
 
28
27
  def authenticate
29
28
  #puts _process_action_callbacks.map(&:filter)
30
- if current_user
31
- session['user_id'] = current_user.id
32
- true
33
- else
34
- session[:return_to] = request.original_url
35
- respond_to do |format|
36
- format.html { redirect_to login_url }
37
- format.any(:xml,:json) { request_http_basic_authentication }
38
- end
39
- false
40
- end
29
+ # if current_user
30
+ # session['user_id'] = current_user.id
31
+ # true
32
+ # else
33
+ # session[:return_to] = request.original_url
34
+ # respond_to do |format|
35
+ # format.html { redirect_to login_url }
36
+ # format.any(:xml,:json) { request_http_basic_authentication }
37
+ # end
38
+ # false
39
+ # end
40
+ true
41
41
  end
42
42
 
43
43
  def authorize
44
44
  #puts _process_action_callbacks.map(&:filter)
45
- action = action_name.to_s.intern
46
- if user_has_access_to_action?(action)
47
- true
48
- else
49
- permissions = self.class.controller_permissions[action]
50
- flash[:error] = permissions[:denied_message] || 'Access denied.'
51
- respond_to do |format|
52
- format.html { redirect_to(permissions[:denied_url] || { :action => :index }) }
53
- format.any(:xml, :json) { head :forbidden }
54
- end
55
- false
56
- end
45
+ # action = action_name.to_s.intern
46
+ # if user_has_access_to_action?(action)
47
+ # true
48
+ # else
49
+ # permissions = self.class.controller_permissions[action]
50
+ # flash[:error] = permissions[:denied_message] || 'Access denied.'
51
+ # respond_to do |format|
52
+ # format.html { redirect_to(permissions[:denied_url] || { :action => :index }) }
53
+ # format.any(:xml, :json) { head :forbidden }
54
+ # end
55
+ # false
56
+ # end
57
+ true
57
58
  end
58
59
 
59
60
  def user_has_access_to_action?(action)
@@ -85,11 +86,6 @@ module LoginSystem
85
86
  end
86
87
 
87
88
  module ClassMethods
88
- def no_login_required
89
- skip_before_action :authenticate
90
- skip_before_action :authorize
91
- # puts _process_action_callbacks.map(&:filter)
92
- end
93
89
 
94
90
  def login_required?
95
91
  filter_chain.any? {|f| f.method == :authenticate || f.method == :authorize }
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Define a namespace for the task
4
+ namespace :import do
5
+ desc 'Imports the legacy user data into the Devise Admin table'
6
+ task admins: :environment do
7
+ LegacyUser.all.each do |legacy|
8
+ u = User.new(
9
+ email: legacy.email,
10
+ first_name: legacy.name.split(' ')[0],
11
+ last_name: legacy.name.split(' ')[1],
12
+ password: 'PleaseChangeMe1!',
13
+ password_confirmation: 'PleaseChangeMe1!',
14
+ admin: legacy.admin,
15
+ designer: legacy.designer,
16
+ content_editor: legacy.content_editor,
17
+ notes: legacy.notes
18
+ )
19
+ u.save!
20
+ end
21
+ end
22
+ end
data/lib/trusty_cms.rb CHANGED
@@ -2,6 +2,6 @@ TRUSTY_CMS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..")) unle
2
2
 
3
3
  unless defined? TrustyCms::VERSION
4
4
  module TrustyCms
5
- VERSION = '3.8.0'
5
+ VERSION = '3.8.1'
6
6
  end
7
7
  end
@@ -183,13 +183,13 @@ module TrustyCms
183
183
  OpenStruct.new.tap do |user|
184
184
  user.preferences = RegionSet.new do |preferences|
185
185
  preferences.main.concat %w{edit_header edit_form}
186
- preferences.form.concat %w{edit_name edit_email edit_username edit_password edit_locale}
186
+ preferences.form.concat %w{edit_first_name edit_last_name edit_email edit_password}
187
187
  preferences.form_bottom.concat %w{edit_buttons}
188
188
  end
189
189
  user.edit = RegionSet.new do |edit|
190
190
  edit.main.concat %w{edit_header edit_form}
191
- edit.form.concat %w{edit_name edit_email edit_username edit_password
192
- edit_roles edit_locale edit_notes}
191
+ edit.form.concat %w{edit_first_name edit_last_name edit_email edit_password
192
+ edit_roles edit_notes}
193
193
  edit.form_bottom.concat %w{edit_buttons edit_timestamp}
194
194
  end
195
195
  user.index = RegionSet.new do |index|
@@ -21,3 +21,5 @@ module TrustyCms
21
21
  end
22
22
 
23
23
  require 'ckeditor'
24
+ require 'devise'
25
+
@@ -17,7 +17,6 @@ module TrustyCms
17
17
  def bootstrap(config)
18
18
  @config = config
19
19
  @admin = create_admin_user(config[:admin_name], config[:admin_username], config[:admin_password])
20
- UserActionObserver.current_user = @admin
21
20
  load_default_configuration
22
21
  # load_database_template(config[:database_template])
23
22
  announce "Finished."
data/trusty_cms.gemspec CHANGED
@@ -26,6 +26,7 @@ a general purpose content managment system--not merely a blogging engine.}
26
26
  s.add_dependency 'acts_as_tree', '>= 2.6.1', '< 2.9.0'
27
27
  s.add_dependency 'ckeditor', '>= 4.2.2', '< 4.3.0'
28
28
  s.add_dependency 'delocalize', '>= 0.2', '< 2.0'
29
+ s.add_dependency 'devise'
29
30
  s.add_dependency 'execjs', '~> 2.7'
30
31
  s.add_dependency 'haml', '~> 5.0'
31
32
  s.add_dependency 'haml-rails', '~> 1.0.0'
@@ -9,8 +9,6 @@ class ClippedExtension < TrustyCms::Extension
9
9
  TrustyCms::AdminUI.send :include, ClippedAdminUI unless defined? admin.asset # defines shards for extension of the asset-admin interface
10
10
  Admin::PagesController.send :helper, Admin::AssetsHelper # currently only provides a description of asset sizes
11
11
  Page.send :include, AssetTags # radius tags for selecting sets of assets and presenting each one
12
- UserActionObserver.instance.send :add_observer!, Asset # the usual creator- and updater-stamping
13
-
14
12
  AssetType.new :image, :icon => 'image', :default_radius_tag => 'image', :processors => [:thumbnail], :styles => :standard, :extensions => %w[jpg jpeg png gif], :mime_types => %w[image/png image/x-png image/jpeg image/pjpeg image/jpg image/gif]
15
13
  AssetType.new :video, :icon => 'video', :processors => [:frame_grab], :styles => :standard, :mime_types => %w[application/x-mp4 video/mpeg video/quicktime video/x-la-asf video/x-ms-asf video/x-msvideo video/x-sgi-movie video/x-flv flv-application/octet-stream video/3gpp video/3gpp2 video/3gpp-tt video/BMPEG video/BT656 video/CelB video/DV video/H261 video/H263 video/H263-1998 video/H263-2000 video/H264 video/JPEG video/MJ2 video/MP1S video/MP2P video/MP2T video/mp4 video/MP4V-ES video/MPV video/mpeg4 video/mpeg4-generic video/nv video/parityfec video/pointer video/raw video/rtx video/ogg video/webm]
16
14
  AssetType.new :audio, :icon => 'audio', :mime_types => %w[audio/mpeg audio/mpg audio/ogg application/ogg audio/x-ms-wma audio/vnd.rn-realaudio audio/x-wav]
@@ -1,7 +1,7 @@
1
1
  module MultiSite::SiteChooserHelper
2
2
 
3
3
  def sites_chooser_thing
4
- return "" unless admin? && defined?(Site) && defined?(controller) && controller.sited_model? && controller.template_name == 'index' && Site.several?
4
+ return "" unless current_user.admin? && defined?(Site) && defined?(controller) && controller.sited_model? && controller.template_name == 'index' && Site.several?
5
5
  options = Site.all.map{ |site| "<li>" + link_to( site.name, "#{request.path}?site_id=#{site.id}", :class => site == current_site ? 'fg' : '') + "</li>" }.join("")
6
6
  chooser = %{<div id="site_chooser">}
7
7
  #chooser << link_to("sites", admin_sites_url, {:id => 'show_site_list', :class => 'expandable'})
@@ -36,8 +36,6 @@ class SnippetsExtension < TrustyCms::Extension
36
36
 
37
37
  admin.snippet ||= TrustyCms::AdminUI.load_default_snippet_regions
38
38
 
39
- UserActionObserver.instance.send :add_observer!, ::Snippet
40
-
41
39
  tab 'Design' do
42
40
  add_item "Snippets", "/admin/snippets"
43
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.0
4
+ version: 3.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrustyCms CMS dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-27 00:00:00.000000000 Z
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_list
@@ -84,6 +84,20 @@ dependencies:
84
84
  - - "<"
85
85
  - !ruby/object:Gem::Version
86
86
  version: '2.0'
87
+ - !ruby/object:Gem::Dependency
88
+ name: devise
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ type: :runtime
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
87
101
  - !ruby/object:Gem::Dependency
88
102
  name: execjs
89
103
  requirement: !ruby/object:Gem::Requirement
@@ -457,6 +471,9 @@ files:
457
471
  - app/assets/images/admin/copy.png
458
472
  - app/assets/images/admin/css_icon.png
459
473
  - app/assets/images/admin/database_icon.png
474
+ - app/assets/images/admin/default_forgot_password.svg
475
+ - app/assets/images/admin/default_reset_password.svg
476
+ - app/assets/images/admin/default_safe_login.svg
460
477
  - app/assets/images/admin/delete.png
461
478
  - app/assets/images/admin/document_icon.png
462
479
  - app/assets/images/admin/document_thumbnail.png
@@ -550,7 +567,6 @@ files:
550
567
  - app/assets/javascripts/admin/assets.js
551
568
  - app/assets/javascripts/admin/assets_admin.js
552
569
  - app/assets/javascripts/admin/autopopulate-breadcrumb.js
553
- - app/assets/javascripts/admin/cookie.js
554
570
  - app/assets/javascripts/admin/datecheck.js
555
571
  - app/assets/javascripts/admin/dropdown.js
556
572
  - app/assets/javascripts/admin/jquery.cookie.js
@@ -621,14 +637,12 @@ files:
621
637
  - app/controllers/admin/page_fields_controller.rb
622
638
  - app/controllers/admin/page_parts_controller.rb
623
639
  - app/controllers/admin/pages_controller.rb
624
- - app/controllers/admin/password_resets_controller.rb
625
640
  - app/controllers/admin/preferences_controller.rb
626
641
  - app/controllers/admin/references_controller.rb
627
642
  - app/controllers/admin/resource_controller.rb
628
643
  - app/controllers/admin/sites_controller.rb
629
644
  - app/controllers/admin/snippets_controller.rb
630
645
  - app/controllers/admin/users_controller.rb
631
- - app/controllers/admin/welcome_controller.rb
632
646
  - app/controllers/application_controller.rb
633
647
  - app/controllers/site_controller.rb
634
648
  - app/controllers/social_mailer_controller.rb
@@ -659,6 +673,7 @@ files:
659
673
  - app/models/file_not_found_page.rb
660
674
  - app/models/haml_filter.rb
661
675
  - app/models/layout.rb
676
+ - app/models/legacy_user.rb
662
677
  - app/models/menu_renderer.rb
663
678
  - app/models/old_page_attachment.rb
664
679
  - app/models/page.rb
@@ -718,8 +733,6 @@ files:
718
733
  - app/views/admin/pages/index.html.haml
719
734
  - app/views/admin/pages/new.html.haml
720
735
  - app/views/admin/pages/remove.html.haml
721
- - app/views/admin/password_resets/edit.html.haml
722
- - app/views/admin/password_resets/new.html.haml
723
736
  - app/views/admin/preferences/edit.html.haml
724
737
  - app/views/admin/references/_tag_reference.haml
725
738
  - app/views/admin/references/filters.haml
@@ -751,11 +764,14 @@ files:
751
764
  - app/views/admin/users/new.html.haml
752
765
  - app/views/admin/users/remove.html.haml
753
766
  - app/views/admin/welcome/login.html.haml
767
+ - app/views/devise/passwords/edit.html.haml
768
+ - app/views/devise/passwords/new.html.haml
769
+ - app/views/devise/sessions/new.html.haml
770
+ - app/views/devise/shared/_links.html.haml
754
771
  - app/views/layouts/application.html.haml
755
772
  - app/views/layouts/mail.html.haml
756
773
  - app/views/layouts/mailer.text.haml
757
774
  - app/views/layouts/trusty.html.haml
758
- - app/views/password_mailer/password_reset.html.haml
759
775
  - app/views/rad_social_mailer/social_mail.html.haml
760
776
  - app/views/rad_social_mailer/social_mail_form.html.haml
761
777
  - app/views/site/not_found.html.haml
@@ -776,6 +792,7 @@ files:
776
792
  - config/environments/test.rb
777
793
  - config/initializers/active_record_extensions.rb
778
794
  - config/initializers/assets.rb
795
+ - config/initializers/devise.rb
779
796
  - config/initializers/interpolation.rb
780
797
  - config/initializers/kraken.rb
781
798
  - config/initializers/response_cache_timeout.rb
@@ -856,6 +873,7 @@ files:
856
873
  - db/migrate/20120209231801_change_pages_allowed_children_cache_to_text.rb
857
874
  - db/migrate/20160527141249_add_password_reset_to_users.rb
858
875
  - db/migrate/20161027141250_add_position_to_pages.rb
876
+ - db/migrate/20200117141251_create_admin_users.rb
859
877
  - db/schema.rb
860
878
  - lib/active_record_extensions/active_record_extensions.rb
861
879
  - lib/annotatable.rb
@@ -970,6 +988,7 @@ files:
970
988
  - lib/tasks/radiant_config.rake
971
989
  - lib/tasks/snippets_extension_tasks.rake
972
990
  - lib/tasks/translate.rake
991
+ - lib/tasks/upgrade_to_devise.rake
973
992
  - lib/translation_support.rb
974
993
  - lib/trusty_cms.rb
975
994
  - lib/trusty_cms/admin_ui.rb