caboose-cms 0.7.54 → 0.7.55

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e77bfc7049d66aec7c82588b4ebc76a526a2c7c2
4
- data.tar.gz: d30b6a71566969ecf0c813c2b72f2e7f9d0a7f88
3
+ metadata.gz: f95a7d0fdab94f7ee1bb8c66944ea56b473d5507
4
+ data.tar.gz: 658a745c061ea7742e6e631ff3f6483ba8ca3808
5
5
  SHA512:
6
- metadata.gz: 28a87f329ba169a6fbe7e51f9e080146cc59f46a7e77341de1ba608a7fffaa026be8f1b65f6b357e55aa8f765117988b5db186b5c2d01eeec2712b500036a350
7
- data.tar.gz: 4a39ed8d4e69925f9cd3de10dc4042e3d821fe58e19131762c01176cb7f788f770b71e2dcd47aa0039e518a5758539025c4e3e75e7767e0cc164d11d8dc1a19b
6
+ metadata.gz: 3283af7c66a5b2cd687ed64b6d8ea32ecfc718d4ac2c0174b27b533731780fd31e8c74cdecd6c8860513a373139da15750c9575b09c548930289ce97a91c51e9
7
+ data.tar.gz: cb3cf3faabf96f629ee86034d7b8d09662d7a310be2fc3c301fcf0685cce208232ad4950bce0049ba5b808e7542af3e12be2a66f74b827062d5e9b7d5f5aac77
@@ -124,21 +124,21 @@ module Caboose
124
124
 
125
125
  # Logs in a user
126
126
  def login_user(user, remember = false)
127
- session["app_user"] = Caboose::StdClass.new(
128
- user.id ,
129
- user.site_id ,
130
- user.first_name ,
131
- user.last_name ,
132
- user.username ,
133
- user.email ,
134
- )
127
+ session["app_user"] = Caboose::StdClass.new({
128
+ :id => user.id ,
129
+ :site_id => user.site_id ,
130
+ :first_name => user.first_name ,
131
+ :last_name => user.last_name ,
132
+ :username => user.username ,
133
+ :email => user.email
134
+ })
135
135
  cookies.permanent[:caboose_user_id] = user.id if remember
136
136
  end
137
137
 
138
138
  # Returns whether or not a user is logged in
139
139
  def logged_in?
140
140
  validate_token
141
- validate_cookie
141
+ validate_cookie
142
142
  return true if !session["app_user"].nil? && session["app_user"] != false && session["app_user"].id != -1 && session["app_user"].id != User::LOGGED_OUT_USER_ID
143
143
  return false
144
144
  end
@@ -172,7 +172,7 @@ module Caboose
172
172
  return User.logged_out_user(@site.id)
173
173
  end
174
174
  #return nil if !logged_in?
175
- return session["app_user"]
175
+ return Caboose::User.where(:id => session["app_user"].id).first
176
176
  end
177
177
 
178
178
  # DEPRECATED: Use user_is_allowed_to(action, resource)
@@ -10,7 +10,8 @@ module Caboose
10
10
  classes = {'zzz_all_domains' => []}
11
11
  Rails.application.config.paths['app/controllers'].each do |controller_path|
12
12
  #files = Dir.glob(Rails.root.join(controller_path, '*.rb'))
13
- files = controller ? Dir.glob(Rails.root.join(controller_path, "#{controller}_controller.rb")) : Dir.glob(Rails.root.join(controller_path, '**/*.rb'))
13
+ #files = controller ? Dir.glob(Rails.root.join(controller_path, "#{controller}_controller.rb")) : Dir.glob(Rails.root.join(controller_path, '**/*.rb'))
14
+ files = controller ? Dir.glob(Rails.root.join(controller_path, "#{controller}_controller.rb")) : Dir.glob(Rails.root.join(controller_path, '*.rb'))
14
15
  for file in files
15
16
  f = Rails.root.join('app', 'controllers', file)
16
17
  f2 = File.open(f, "r")
@@ -81,7 +81,7 @@ module Caboose
81
81
  and O.date_authorized < ?
82
82
  group by concat(SA.city, ', ', SA.state), SA.state, SA.city
83
83
  order by SA.state, SA.city",
84
- site_id, 'authorized', 'captured', d1, d2]
84
+ site_id, 'authorized', 'captured', d1, d2]
85
85
  rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, q))
86
86
 
87
87
  arr = []
@@ -96,60 +96,4 @@ class Caboose::User < ActiveRecord::Base
96
96
  return nil
97
97
  end
98
98
 
99
- #def marshal_dump
100
- # [
101
- # self.id ,
102
- # self.site_id ,
103
- # self.first_name ,
104
- # self.last_name ,
105
- # self.username ,
106
- # self.email ,
107
- # self.address ,
108
- # self.address2 ,
109
- # self.city ,
110
- # self.state ,
111
- # self.zip ,
112
- # self.phone ,
113
- # self.fax ,
114
- # self.timezone ,
115
- # self.password ,
116
- # self.password_reset_id ,
117
- # self.password_reset_sent ,
118
- # self.token ,
119
- # self.date_created ,
120
- # self.image ,
121
- # self.is_guest ,
122
- # self.customer_profile_id ,
123
- # self.payment_profile_id ,
124
- # self.locked
125
- # ]
126
- #end
127
- #
128
- #def marshal_load array
129
- # self.id ,
130
- # self.site_id ,
131
- # self.first_name ,
132
- # self.last_name ,
133
- # self.username ,
134
- # self.email ,
135
- # self.address ,
136
- # self.address2 ,
137
- # self.city ,
138
- # self.state ,
139
- # self.zip ,
140
- # self.phone ,
141
- # self.fax ,
142
- # self.timezone ,
143
- # self.password ,
144
- # self.password_reset_id ,
145
- # self.password_reset_sent ,
146
- # self.token ,
147
- # self.date_created ,
148
- # self.image ,
149
- # self.is_guest ,
150
- # self.customer_profile_id ,
151
- # self.payment_profile_id ,
152
- # self.locked = array
153
- #end
154
-
155
99
  end
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.7.54'
2
+ VERSION = '0.7.55'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.54
4
+ version: 0.7.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -761,7 +761,6 @@ files:
761
761
  - app/mailers/caboose/caboose_mailer.rb
762
762
  - app/mailers/caboose/login_mailer.rb
763
763
  - app/mailers/caboose/orders_mailer.rb
764
- - app/models/caboose/#user.rb#
765
764
  - app/models/caboose/ab_option.rb
766
765
  - app/models/caboose/ab_testing.rb
767
766
  - app/models/caboose/ab_value.rb
@@ -1,155 +0,0 @@
1
- class Caboose::User < ActiveRecord::Base
2
- self.table_name = "users"
3
-
4
- belongs_to :site, :class_name => 'Caboose::Site'
5
- has_many :role_memberships
6
- has_many :roles, :through => :role_memberships
7
- has_attached_file :image,
8
- :path => ':caboose_prefixusers/:id_:style.:extension',
9
- :default_url => 'http://placehold.it/300x300',
10
- :styles => {
11
- :tiny => '150x200>',
12
- :thumb => '300x400>',
13
- :large => '600x800>'
14
- }
15
- do_not_validate_attachment_file_type :image
16
- attr_accessible :id, :site_id, :email, :first_name, :last_name, :username, :token, :password, :phone, :timezone
17
-
18
- validates :email, :presence => true
19
-
20
- ADMIN_USER_ID = 1
21
- LOGGED_OUT_USER_ID = 2
22
-
23
- before_save do
24
- self.email = self.email.downcase if self.email
25
- end
26
-
27
- def self.logged_out_user(site_id)
28
- return self.where(:site_id => site_id, :username => 'elo').first
29
- #return self.where(:id => self::LOGGED_OUT_USER_ID).first
30
- end
31
-
32
- def self.logged_out_user_id(site_id)
33
- return self.where(:site_id => site_id, :username => 'elo').limit(1).pluck(:id)[0]
34
- #return self::LOGGED_OUT_USER_ID
35
- end
36
-
37
- def is_logged_out_user?
38
- return self.id == Caboose::User.logged_out_user_id(self.site_id)
39
- end
40
-
41
- def is_allowed(resource, action)
42
- elo = Caboose::Role.logged_out_role(self.site_id)
43
- elo_is_allowed = elo.is_allowed(resource, action)
44
- return true if elo_is_allowed
45
- return false if !elo_is_allowed && self.is_logged_out_user?
46
- eli = Caboose::Role.logged_in_role(self.site_id)
47
- return true if self.id != elo.id && eli.is_allowed(resource, action)
48
- for role in roles
49
- #Caboose.log("Checking permissions for #{role.name} role")
50
- if role.is_allowed(resource, action)
51
- #Caboose.log("Role #{role.name} is allowed to view page")
52
- return true
53
- else
54
- #Caboose.log("Role #{role.name} is not allowed to view page")
55
- end
56
- #return true if role.is_allowed(resource, action)
57
- end
58
- return false;
59
- end
60
-
61
- def self.validate_token(token)
62
- user = self.where('token' => token).first
63
- return user
64
- end
65
-
66
- def add_to_role_with_name(role_name)
67
- r = Caboose::Role.where(:name => role_name).first
68
- return false if r.nil?
69
- return add_to_role(r.id)
70
- end
71
-
72
- def add_to_role(role_id)
73
- r = Caboose::Role.find(role_id)
74
- return false if r.nil?
75
-
76
- if (!is_member?(r.id))
77
- roles.push r
78
- save
79
- end
80
- return true
81
- end
82
-
83
- def is_member?(role_id)
84
- roles.each do |r|
85
- return true if (r.id == role_id)
86
- end
87
- return false
88
- end
89
-
90
- def self.user_for_reset_id(reset_id)
91
- return nil if reset_id.nil?
92
- d = DateTime.now - 3.days
93
- if self.where("password_reset_id = ? and password_reset_sent > ?", reset_id, d).exists?
94
- return self.where("password_reset_id = ? and password_reset_sent > ?", reset_id, d).first
95
- end
96
- return nil
97
- end
98
-
99
- #def marshal_dump
100
- # [
101
- # self.id ,
102
- # self.site_id ,
103
- # self.first_name ,
104
- # self.last_name ,
105
- # self.username ,
106
- # self.email ,
107
- # self.address ,
108
- # self.address2 ,
109
- # self.city ,
110
- # self.state ,
111
- # self.zip ,
112
- # self.phone ,
113
- # self.fax ,
114
- # self.timezone ,
115
- # self.password ,
116
- # self.password_reset_id ,
117
- # self.password_reset_sent ,
118
- # self.token ,
119
- # self.date_created ,
120
- # self.image ,
121
- # self.is_guest ,
122
- # self.customer_profile_id ,
123
- # self.payment_profile_id ,
124
- # self.locked
125
- # ]
126
- #end
127
- #
128
- #def marshal_load array
129
- # self.id ,
130
- # self.site_id ,
131
- # self.first_name ,
132
- # self.last_name ,
133
- # self.username ,
134
- # self.email ,
135
- # self.address ,
136
- # self.address2 ,
137
- # self.city ,
138
- # self.state ,
139
- # self.zip ,
140
- # self.phone ,
141
- # self.fax ,
142
- # self.timezone ,
143
- # self.password ,
144
- # self.password_reset_id ,
145
- # self.password_reset_sent ,
146
- # self.token ,
147
- # self.date_created ,
148
- # self.image ,
149
- # self.is_guest ,
150
- # self.customer_profile_id ,
151
- # self.payment_profile_id ,
152
- # self.locked = array
153
- #end
154
-
155
- end