radiant-reader-extension 1.3.9 → 1.3.10

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.9
1
+ 1.3.10
@@ -41,7 +41,7 @@ class ReaderSessionsController < ReaderActionController
41
41
  @reader_session = ReaderSession.new(params[:reader_session])
42
42
  if @reader_session.save
43
43
  if @reader_session.reader.activated? && @reader_session.reader.clear_password
44
- @reader_session.reader.clear_password = "" # we forget the cleartext version on the first successful login after activation
44
+ @reader_session.reader.clear_password = "" # we forget the cleartext version on the first successful login
45
45
  @reader_session.reader.save(false)
46
46
  end
47
47
  respond_to do |format|
data/app/models/reader.rb CHANGED
@@ -26,11 +26,10 @@ class Reader < ActiveRecord::Base
26
26
  attr_accessor :current_password # used for authentication on update
27
27
  attr_accessor :email_field # used in blocking spam registrations
28
28
 
29
- before_save :set_login
30
29
  before_update :update_user
31
30
 
32
31
  validates_presence_of :name, :email, :message => 'is required'
33
- validates_uniqueness_of :login, :message => "is already in use here"
32
+ validates_uniqueness_of :login, :message => "is already in use here", :allow_blank => true
34
33
  validate :email_must_not_be_in_use
35
34
 
36
35
  include RFC822
@@ -89,13 +88,8 @@ class Reader < ActiveRecord::Base
89
88
  message.deliver_to(self)
90
89
  end
91
90
 
92
- def generate_password(length=12)
93
- chars = ("a".."z").to_a + ("A".."Z").to_a + ("1".."9").to_a
94
- Array.new(length, '').collect{chars[rand(chars.size)]}.join
95
- end
96
-
97
91
  def generate_email_field_name
98
- self.email_field = generate_password(32)
92
+ self.email_field = Authlogic::Random.friendly_token
99
93
  end
100
94
 
101
95
  def is_user?
@@ -122,37 +116,37 @@ class Reader < ActiveRecord::Base
122
116
  reader
123
117
  end
124
118
 
125
- protected
119
+ def create_password!
120
+ self.clear_password = self.randomize_password # randomize_password is provided by authlogic
121
+ self.save! unless self.new_record?
122
+ self.clear_password
123
+ end
126
124
 
127
- def set_login
128
- self.login = self.email if self.login.blank?
129
- end
125
+ private
130
126
 
131
- private
132
-
133
- def email_must_not_be_in_use
134
- reader = Reader.find_by_email(self.email) # the finds will be site-scoped if appropriate
135
- user = User.find_by_email(self.email)
136
- if user && user != self.user
137
- errors.add(:email, "belongs to an author here")
138
- elsif reader && reader != self
139
- errors.add(:email, "is already registered here")
140
- else
141
- return true
142
- end
143
- return false
127
+ def email_must_not_be_in_use
128
+ reader = Reader.find_by_email(self.email) # the finds will be site-scoped if appropriate
129
+ user = User.find_by_email(self.email)
130
+ if user && user != self.user
131
+ errors.add(:email, "belongs to an author already known here")
132
+ elsif reader && reader != self
133
+ errors.add(:email, "is already registered here")
134
+ else
135
+ return true
144
136
  end
137
+ return false
138
+ end
145
139
 
146
- def validate_length_of_password?
147
- new_record? or not password.to_s.empty?
148
- end
140
+ def validate_length_of_password?
141
+ new_record? or not password.to_s.empty?
142
+ end
149
143
 
150
- def update_user
151
- if self.user
152
- user_columns.each { |att| self.user.send("#{att.to_s}=", send(att)) if send("#{att.to_s}_changed?") }
153
- self.user.password_confirmation = password_confirmation if password_changed?
154
- self.user.save! if self.user.changed?
155
- end
144
+ def update_user
145
+ if self.user
146
+ user_columns.each { |att| self.user.send("#{att.to_s}=", send(att)) if send("#{att.to_s}_changed?") }
147
+ self.user.password_confirmation = password_confirmation if password_changed?
148
+ self.user.save! if self.user.changed?
156
149
  end
150
+ end
157
151
 
158
152
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-reader-extension}
8
- s.version = "1.3.9"
8
+ s.version = "1.3.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["spanner"]
data/reader_extension.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_dependency 'application_controller'
2
2
 
3
3
  class ReaderExtension < Radiant::Extension
4
- version "1.3.9"
4
+ version "1.3.10"
5
5
  description "Provides reader/member/user registration and management functions"
6
6
  url "http://spanner.org/radiant/reader"
7
7
 
@@ -41,10 +41,6 @@ describe ReadersController do
41
41
  @reader.email.should == 'registrant@spanner.org'
42
42
  end
43
43
 
44
- it "should have defaulted to email address as login" do
45
- @reader.login.should == @reader.email
46
- end
47
-
48
44
  if defined? Site
49
45
  it "should have assigned the new reader to the current site" do
50
46
  @reader.site.should == sites(:test)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-reader-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 9
10
- version: 1.3.9
9
+ - 10
10
+ version: 1.3.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - spanner