caboose-cms 0.7.53 → 0.7.54

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: e1c25efdd92fb196e5661e1c86472abaf5e79e16
4
- data.tar.gz: 13b850bc5278f2830e4f161dcb0daeaf6e7fa04e
3
+ metadata.gz: e77bfc7049d66aec7c82588b4ebc76a526a2c7c2
4
+ data.tar.gz: d30b6a71566969ecf0c813c2b72f2e7f9d0a7f88
5
5
  SHA512:
6
- metadata.gz: 06cfd11597bc1334919febeb206504ffef3ea4642b4f3a8821ae7b41898a41548aece70d8c3f9e6f5ce014b1f911cb3c7c4d5558e0e36bec812b0e26f4ba1e7d
7
- data.tar.gz: 88880a095e686f5e7a6e5fe26d72522dbe0adf73426d9922709f3f89fe07554514e02a785ca2ac590497f4a54daab25cb17ec0bf9a75c0363afd113a5c681833
6
+ metadata.gz: 28a87f329ba169a6fbe7e51f9e080146cc59f46a7e77341de1ba608a7fffaa026be8f1b65f6b357e55aa8f765117988b5db186b5c2d01eeec2712b500036a350
7
+ data.tar.gz: 4a39ed8d4e69925f9cd3de10dc4042e3d821fe58e19131762c01176cb7f788f770b71e2dcd47aa0039e518a5758539025c4e3e75e7767e0cc164d11d8dc1a19b
@@ -124,7 +124,14 @@ module Caboose
124
124
 
125
125
  # Logs in a user
126
126
  def login_user(user, remember = false)
127
- session["app_user"] = user
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
+ )
128
135
  cookies.permanent[:caboose_user_id] = user.id if remember
129
136
  end
130
137
 
@@ -0,0 +1,155 @@
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
@@ -96,60 +96,60 @@ 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
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
154
 
155
155
  end
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.7.53'
2
+ VERSION = '0.7.54'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.53
4
+ version: 0.7.54
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
@@ -761,6 +761,7 @@ 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#
764
765
  - app/models/caboose/ab_option.rb
765
766
  - app/models/caboose/ab_testing.rb
766
767
  - app/models/caboose/ab_value.rb