trusty-cms 2.0.20 → 2.0.21.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +7 -5
  4. data/Gemfile.lock +32 -20
  5. data/app/assets/images/admin/add_tab.png +0 -0
  6. data/app/assets/images/admin/avatar_32x32.png +0 -0
  7. data/app/assets/images/admin/avatar_64x64.png +0 -0
  8. data/app/assets/images/admin/avatar_96x96.png +0 -0
  9. data/app/assets/images/admin/calendar_down.png +0 -0
  10. data/app/assets/images/admin/collapse.png +0 -0
  11. data/app/assets/images/admin/collapsed.png +0 -0
  12. data/app/assets/images/admin/draft_page.png +0 -0
  13. data/app/assets/images/admin/image.png +0 -0
  14. data/app/assets/images/admin/javascript.png +0 -0
  15. data/app/assets/images/admin/layout.png +0 -0
  16. data/app/assets/images/admin/metadata_toggle.png +0 -0
  17. data/app/assets/images/admin/minus.png +0 -0
  18. data/app/assets/images/admin/minus_disabled.png +0 -0
  19. data/app/assets/images/admin/minus_grey.png +0 -0
  20. data/app/assets/images/admin/navigation_secondary_separator.png +0 -0
  21. data/app/assets/images/admin/page.png +0 -0
  22. data/app/assets/images/admin/plus.png +0 -0
  23. data/app/assets/images/admin/plus_disabled.png +0 -0
  24. data/app/assets/images/admin/plus_grey.png +0 -0
  25. data/app/assets/images/admin/popup_border_background.png +0 -0
  26. data/app/assets/images/admin/popup_border_bottom_left.png +0 -0
  27. data/app/assets/images/admin/popup_border_bottom_right.png +0 -0
  28. data/app/assets/images/admin/popup_border_top_left.png +0 -0
  29. data/app/assets/images/admin/popup_border_top_right.png +0 -0
  30. data/app/assets/images/admin/search.png +0 -0
  31. data/app/assets/images/admin/single_form_shadow.png +0 -0
  32. data/app/assets/images/admin/snippet.png +0 -0
  33. data/app/assets/images/admin/status_background.png +0 -0
  34. data/app/assets/images/admin/status_bottom_left.png +0 -0
  35. data/app/assets/images/admin/status_bottom_right.png +0 -0
  36. data/app/assets/images/admin/status_top_left.png +0 -0
  37. data/app/assets/images/admin/status_top_right.png +0 -0
  38. data/app/assets/images/admin/stylesheet.png +0 -0
  39. data/app/assets/images/admin/tab_close.png +0 -0
  40. data/app/assets/images/admin/ui-bg_flat_75_ffffff_40x100.png +0 -0
  41. data/app/assets/images/admin/ui-bg_glass_65_ffffff_1x400.png +0 -0
  42. data/app/assets/images/admin/ui-icons_222222_256x240.png +0 -0
  43. data/app/assets/images/admin/ui-icons_2e83ff_256x240.png +0 -0
  44. data/app/assets/images/admin/ui-icons_454545_256x240.png +0 -0
  45. data/app/assets/images/admin/ui-icons_888888_256x240.png +0 -0
  46. data/app/assets/images/admin/ui-icons_cd0a0a_256x240.png +0 -0
  47. data/app/assets/images/admin/upload.png +0 -0
  48. data/app/assets/images/admin/virtual_page.png +0 -0
  49. data/app/assets/images/radiant/radiant-badge-color.png +0 -0
  50. data/app/controllers/admin/password_resets_controller.rb +25 -0
  51. data/app/mailers/password_mailer.rb +8 -0
  52. data/app/models/user.rb +28 -18
  53. data/app/views/admin/password_resets/edit.html.haml +23 -0
  54. data/app/views/admin/password_resets/new.html.haml +14 -0
  55. data/app/views/admin/welcome/login.html.haml +1 -0
  56. data/app/views/password_mailer/password_reset.html.haml +3 -0
  57. data/config/routes.rb +1 -0
  58. data/coverage/assets/0.10.0/application.css +799 -0
  59. data/coverage/assets/0.10.0/application.js +1707 -0
  60. data/coverage/assets/0.10.0/colorbox/border.png +0 -0
  61. data/coverage/assets/0.10.0/colorbox/controls.png +0 -0
  62. data/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
  63. data/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
  64. data/coverage/assets/0.10.0/favicon_green.png +0 -0
  65. data/coverage/assets/0.10.0/favicon_red.png +0 -0
  66. data/coverage/assets/0.10.0/favicon_yellow.png +0 -0
  67. data/coverage/assets/0.10.0/loading.gif +0 -0
  68. data/coverage/assets/0.10.0/magnify.png +0 -0
  69. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  70. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  71. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  72. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  73. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  74. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  75. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  76. data/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  77. data/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
  78. data/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  79. data/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
  80. data/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
  81. data/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  82. data/coverage/index.html +6306 -0
  83. data/db/migrate/20160527141249_add_password_reset_to_users.rb +6 -0
  84. data/lib/trusty_cms.rb +1 -1
  85. data/spec/controllers/application_controller_spec.rb +60 -0
  86. data/spec/controllers/users_controller_spec.rb +6 -0
  87. data/spec/controllers/welcome_controller_spec.rb +6 -0
  88. data/spec/dummy/db/schema.rb +3 -3
  89. data/spec/dummy/log/development.log +1 -0
  90. data/spec/dummy/log/test.log +16101 -0
  91. data/spec/dummy/tmp/cache/747/A70/TrustyCms%3A%3AConfig +0 -0
  92. data/spec/dummy/tmp/cache/85C/FA0/TrustyCms.cache_mtime +0 -0
  93. data/spec/factories/layout.rb +17 -0
  94. data/spec/factories/page.rb +63 -0
  95. data/spec/factories/page_part.rb +8 -0
  96. data/spec/factories/user.rb +35 -0
  97. data/spec/models/layout_spec.rb +29 -0
  98. data/spec/routing/welcome_routing_spec.rb +18 -0
  99. data/spec/spec_helper.rb +11 -2
  100. data/trusty_cms.gemspec +1 -1
  101. metadata +57 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5276d4fafa219de785fbdde6856bd2669364f433
4
- data.tar.gz: 2588f19ddb0ade42aaa53a5e652c0a531739cd1e
3
+ metadata.gz: 2a70dc8977477fc05f0c0f564bc8c16f4ceb5af1
4
+ data.tar.gz: 6aadac44daf584414af090b62ce6b8e1fee405ac
5
5
  SHA512:
6
- metadata.gz: 4b59e1e8af5830a094004749b4402ee3c36ef531f7e450c1cc5b37bddcb7107d093241271b4c31c1be85992597126c2ae8f8dbe375796ff9573530ee8fb789b7
7
- data.tar.gz: 79fa037ac0f4b9777610e36dc5fd510dee24b90be800f11d03bb113c6d93c798446e03174ea786ca7eb85a592c71ff218e75794f1f13c703d3418de2f661e717
6
+ metadata.gz: 39b212b91013312d84f24890b0f54295987f3500f1989bdf2c45c118c361d1308f4ca70691f4f4f8630968f4336b6d29d33330269eade03ac8a3e235a1bc1ab8
7
+ data.tar.gz: fb688c23a8a656026905e7e01b0697f3e074f93e77bb42192e45ad752525fbdb115f8cef2784323e1f0e8c81437c9dc66c0c2f97acdf0657a10fd5e279e2e756
data/.gitignore CHANGED
@@ -27,3 +27,4 @@ trusty-cms.box
27
27
  .vagrant
28
28
  *.gem
29
29
  .sass-cache
30
+ /coverage/*
data/Gemfile CHANGED
@@ -33,7 +33,7 @@ gemspec
33
33
 
34
34
 
35
35
  group :development, :test do
36
- gem "compass-rails", "~> 2.0.1"
36
+ gem 'compass-rails', '~> 2.0.1'
37
37
  gem 'thin', '~> 1.6.2'
38
38
  gem 'pry', '~> 0.10.0'
39
39
  gem 'capybara', '~> 2.3.0'
@@ -41,10 +41,12 @@ group :development, :test do
41
41
  gem 'launchy', '~> 2.4.2'
42
42
  gem 'database_cleaner', '~> 1.3.0'
43
43
  gem 'poltergeist', '~> 1.5.1'
44
- gem "ckeditor", "~> 4.1.0"
45
- gem 'factory_girl_rails', '~> 4.5.0'
44
+ gem 'ckeditor', '~> 4.1.0'
45
+ gem 'factory_girl_rails', '~> 4.6.0'
46
46
  gem 'rails-observers'
47
- gem "protected_attributes"
48
- gem "pry-byebug"
47
+ gem 'protected_attributes'
48
+ gem 'pry-rails'
49
49
  gem 'mysql2', '~> 0.4.2'
50
+ gem 'pry-byebug'
51
+ gem 'simplecov'
50
52
  end
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (2.0.20)
5
- RedCloth (~> 4.2)
4
+ trusty-cms (2.0.21.alpha)
5
+ RedCloth (~> 4.3.2)
6
6
  acts_as_tree (~> 2.1)
7
7
  bundler (~> 1.7)
8
8
  ckeditor (~> 4.1)
@@ -30,7 +30,7 @@ PATH
30
30
  GEM
31
31
  remote: https://rubygems.org/
32
32
  specs:
33
- RedCloth (4.2.9)
33
+ RedCloth (4.3.2)
34
34
  actionmailer (4.2.6)
35
35
  actionpack (= 4.2.6)
36
36
  actionview (= 4.2.6)
@@ -71,7 +71,7 @@ GEM
71
71
  addressable (2.4.0)
72
72
  arel (6.0.3)
73
73
  builder (3.2.2)
74
- byebug (8.2.2)
74
+ byebug (9.0.4)
75
75
  capybara (2.3.0)
76
76
  mime-types (>= 1.16)
77
77
  nokogiri (>= 1.3.3)
@@ -109,13 +109,14 @@ GEM
109
109
  delocalize (0.4.0)
110
110
  rails (>= 3.0)
111
111
  diff-lcs (1.2.5)
112
+ docile (1.1.5)
112
113
  erubis (2.7.0)
113
- eventmachine (1.0.9.1)
114
- eventmachine (1.0.9.1-java)
115
- execjs (2.6.0)
114
+ eventmachine (1.2.0.1)
115
+ eventmachine (1.2.0.1-java)
116
+ execjs (2.7.0)
116
117
  factory_girl (4.5.0)
117
118
  activesupport (>= 3.0.0)
118
- factory_girl_rails (4.5.0)
119
+ factory_girl_rails (4.6.0)
119
120
  factory_girl (~> 4.5.0)
120
121
  railties (>= 3.0.0)
121
122
  ffi (1.9.10)
@@ -148,17 +149,19 @@ GEM
148
149
  launchy (2.4.3-java)
149
150
  addressable (~> 2.3)
150
151
  spoon (~> 0.0.1)
151
- libv8 (3.16.14.13)
152
+ libv8 (3.16.14.15)
152
153
  loofah (2.0.3)
153
154
  nokogiri (>= 1.5.9)
154
155
  mail (2.6.4)
155
156
  mime-types (>= 1.16, < 4)
156
157
  method_source (0.8.2)
157
- mime-types (2.99.1)
158
+ mime-types (3.1)
159
+ mime-types-data (~> 3.2015)
160
+ mime-types-data (3.2016.0521)
158
161
  mini_portile2 (2.0.0)
159
- minitest (5.8.4)
160
- multi_json (1.11.2)
161
- mysql2 (0.4.3)
162
+ minitest (5.9.0)
163
+ multi_json (1.12.1)
164
+ mysql2 (0.4.4)
162
165
  nokogiri (1.6.7.2)
163
166
  mini_portile2 (~> 2.0.0.rc2)
164
167
  nokogiri (1.6.7.2-java)
@@ -179,9 +182,11 @@ GEM
179
182
  method_source (~> 0.8.1)
180
183
  slop (~> 3.4)
181
184
  spoon (~> 0.0)
182
- pry-byebug (3.3.0)
183
- byebug (~> 8.0)
185
+ pry-byebug (3.4.0)
186
+ byebug (~> 9.0)
184
187
  pry (~> 0.10)
188
+ pry-rails (0.3.4)
189
+ pry (>= 0.9.10)
185
190
  rack (1.6.4)
186
191
  rack-cache (1.6.1)
187
192
  rack (>= 0.4)
@@ -237,9 +242,9 @@ GEM
237
242
  rspec-mocks (~> 3.0.0)
238
243
  rspec-support (~> 3.0.0)
239
244
  rspec-support (3.0.4)
240
- ruby_parser (3.8.1)
245
+ ruby_parser (3.8.2)
241
246
  sexp_processor (~> 4.1)
242
- sass (3.4.21)
247
+ sass (3.4.22)
243
248
  sass-rails (5.0.4)
244
249
  railties (>= 4.0.0, < 5.0)
245
250
  sass (~> 3.1)
@@ -247,6 +252,11 @@ GEM
247
252
  sprockets-rails (>= 2.0, < 4.0)
248
253
  tilt (>= 1.1, < 3)
249
254
  sexp_processor (4.7.0)
255
+ simplecov (0.11.2)
256
+ docile (~> 1.1.0)
257
+ json (~> 1.8)
258
+ simplecov-html (~> 0.10.0)
259
+ simplecov-html (0.10.0)
250
260
  slop (3.6.0)
251
261
  spoon (0.0.4)
252
262
  ffi
@@ -278,9 +288,9 @@ GEM
278
288
  uglifier (2.7.2)
279
289
  execjs (>= 0.3.0)
280
290
  json (>= 1.8.0)
281
- websocket-driver (0.6.3)
291
+ websocket-driver (0.6.4)
282
292
  websocket-extensions (>= 0.1.0)
283
- websocket-driver (0.6.3-java)
293
+ websocket-driver (0.6.4-java)
284
294
  websocket-extensions (>= 0.1.0)
285
295
  websocket-extensions (0.1.2)
286
296
  will_paginate (3.1.0)
@@ -296,15 +306,17 @@ DEPENDENCIES
296
306
  ckeditor (~> 4.1.0)
297
307
  compass-rails (~> 2.0.1)
298
308
  database_cleaner (~> 1.3.0)
299
- factory_girl_rails (~> 4.5.0)
309
+ factory_girl_rails (~> 4.6.0)
300
310
  launchy (~> 2.4.2)
301
311
  mysql2 (~> 0.4.2)
302
312
  poltergeist (~> 1.5.1)
303
313
  protected_attributes
304
314
  pry (~> 0.10.0)
305
315
  pry-byebug
316
+ pry-rails
306
317
  rails-observers
307
318
  rspec-rails (~> 3.0.0)
319
+ simplecov
308
320
  thin (~> 1.6.2)
309
321
  trusty-cms!
310
322
  trustygems (~> 0.2.0)
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ class Admin::PasswordResetsController < ApplicationController
2
+ no_login_required
3
+ skip_before_filter :verify_authenticity_token
4
+
5
+ def create
6
+ user = User.find_by_email(params[:email])
7
+ user.send_password_reset if user
8
+ redirect_to welcome_path, :notice => "Email sent with password reset instructions."
9
+ end
10
+
11
+ def edit
12
+ @user = User.find_by_password_reset_token!(params[:id])
13
+ end
14
+
15
+ def update
16
+ @user = User.find_by_password_reset_token!(params[:id])
17
+ if @user.password_reset_sent_at < 2.hours.ago
18
+ redirect_to new_password_reset_path, :alert => "Password reset has expired."
19
+ elsif @user.update_attributes(params[:user])
20
+ redirect_to welcome_url, :notice => "Password has been reset!"
21
+ else
22
+ render :edit
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ class PasswordMailer < ActionMailer::Base
2
+
3
+ def password_reset(user)
4
+ @user = user
5
+ mail :to => user.email, :subject => "Password Reset for TrustyCMS"
6
+ end
7
+
8
+ end
data/app/models/user.rb CHANGED
@@ -60,28 +60,38 @@ class User < ActiveRecord::Base
60
60
  update_attribute(:session_token, nil)
61
61
  end
62
62
 
63
+ def send_password_reset
64
+ generate_token(:password_reset_token)
65
+ update_attribute(:password_reset_sent_at, Time.zone.now)
66
+ PasswordMailer.password_reset(self).deliver_now
67
+ end
68
+
63
69
  private
64
70
 
65
- def validate_length_of_password?
66
- new_record? or not password.to_s.empty?
67
- end
71
+ def generate_token(column)
72
+ self[column] = SecureRandom.urlsafe_base64 if User.exists?(column => self[column])
73
+ end
68
74
 
69
- before_create :encrypt_password
70
- def encrypt_password
71
- self.salt = Digest::SHA1.hexdigest("--#{Time.now}--#{login}--sweet harmonious biscuits--")
72
- self.password = sha1(password)
73
- end
75
+ def validate_length_of_password?
76
+ new_record? or not password.to_s.empty?
77
+ end
78
+
79
+ before_create :encrypt_password
80
+ def encrypt_password
81
+ self.salt = Digest::SHA1.hexdigest("--#{Time.now}--#{login}--sweet harmonious biscuits--")
82
+ self.password = sha1(password)
83
+ end
74
84
 
75
- before_update :encrypt_password_unless_empty_or_unchanged
76
- def encrypt_password_unless_empty_or_unchanged
77
- user = self.class.find(self.id)
78
- case password
79
- when ''
80
- self.password = user.password
81
- when user.password
82
- else
83
- encrypt_password
84
- end
85
+ before_update :encrypt_password_unless_empty_or_unchanged
86
+ def encrypt_password_unless_empty_or_unchanged
87
+ user = self.class.find(self.id)
88
+ case password
89
+ when ''
90
+ self.password = user.password
91
+ when user.password
92
+ else
93
+ encrypt_password
85
94
  end
95
+ end
86
96
 
87
97
  end
@@ -0,0 +1,23 @@
1
+ %h1= t('reset_your_password')
2
+
3
+ = form_for @user, :url => admin_password_reset_path(params[:id]) do |f|
4
+ - if @user.errors.any?
5
+ .error_messages
6
+ %h2 Form is invalid
7
+ %ul
8
+ - for message in @user.errors.full_messages
9
+ %li= message
10
+ %p
11
+ %label{:for=>"password"}= t('password')
12
+ = f.password_field :password
13
+ %p
14
+ %label{:for=>"password_confirmation"}= t('password_confirmation')
15
+ = f.password_field :password_confirmation
16
+ .actions= f.submit "Update Password"
17
+
18
+ %p.version
19
+ = t('powered_by')
20
+ %a{ :href => "https://github.com/pgharts/trusty-cms" } TrustyCms CMS
21
+ = t('version')
22
+ = TrustyCms.loaded_via_gem? ? "#{TrustyCms::VERSION} (gem)." : "#{TrustyCms::VERSION}."
23
+
@@ -0,0 +1,14 @@
1
+ %h1= t('reset_your_password')
2
+
3
+ = form_tag admin_password_resets_path, :method => :post do
4
+ %p
5
+ %label{:for=>"email"}= t('email')
6
+ = text_field_tag :email, params[:email], :class => 'textbox', :maxlength => 70, :size => 70
7
+ .actions
8
+ = submit_tag "Reset Password"
9
+
10
+ %p.version
11
+ = t('powered_by')
12
+ %a{ :href => "https://github.com/pgharts/trusty-cms" } TrustyCms CMS
13
+ = t('version')
14
+ = TrustyCms.loaded_via_gem? ? "#{TrustyCms::VERSION} (gem)." : "#{TrustyCms::VERSION}."
@@ -10,6 +10,7 @@
10
10
  %p
11
11
  %label{:for=>"password"}= t('password')
12
12
  = password_field_tag "password", '', :class => 'textbox password', :maxlength => 40, :size => 40
13
+ %p= link_to "Forgot password?", new_admin_password_reset_path
13
14
  %p.remember_me
14
15
  = check_box_tag :remember_me, 1, false, :class => 'checkbox'
15
16
  %label.checkbox{:for=>"remember_me"}= t('remember_me_in_this_browser')
@@ -0,0 +1,3 @@
1
+ = link_to('Reset Your Password', edit_admin_password_reset_url(@user.password_reset_token))
2
+
3
+ If you did not request your password to be reset, please alert your TrustyCMS Admin.
data/config/routes.rb CHANGED
@@ -15,6 +15,7 @@ TrustyCms::Application.routes.draw do
15
15
  resources :users do
16
16
  get 'remove', on: :member
17
17
  end
18
+ resources :password_resets
18
19
  end
19
20
 
20
21
  match 'admin/preview' => 'admin/pages#preview', :as => :preview, :via => [:post, :put]