public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Search Repo:
Last of the polish on email_verified
Michael Hartl (author)
Wed May 21 11:50:03 -0700 2008
commit  b2442c9a907ba387eaf6374367979b048293b88a
tree    1399e52f21ceed89052ae6b3e1ef409343454d04
parent  983283f3dc62c08424cc26aaf133c4402797346c
...
16
17
18
19
20
 
 
21
22
23
...
16
17
18
 
 
19
20
21
22
23
0
@@ -16,8 +16,8 @@ class PeopleController < ApplicationController
0
   
0
   def show
0
     @person = Person.find(params[:id], :include => :activities)
0
- if @person.deactivated? and not current_person.admin?
0
- flash[:error] = "That person is not activated"
0
+ unless @person.active? or current_person.admin?
0
+ flash[:error] = "That person is not active"
0
       redirect_to home_url and return
0
     end
0
     if logged_in?
...
13
14
15
16
 
 
17
18
19
...
13
14
15
 
16
17
18
19
20
0
@@ -13,7 +13,8 @@ class SessionsController < ApplicationController
0
       if person.deactivated?
0
         flash[:error] = "Your account has been deactivated"
0
         redirect_to home_url and return
0
- elsif global_prefs.email_verifications? and not person.email_verified?
0
+ elsif global_prefs.email_verifications? and
0
+ not person.email_verified? and not person.admin?
0
         flash[:notice] = %(Unverified email address.
0
                            Please check your email for your activation code.)
0
         redirect_to login_url and return
...
1
2
3
 
 
 
 
 
 
 
 
4
5
6
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -1,6 +1,14 @@
0
 class AddEmailVerified < ActiveRecord::Migration
0
   def self.up
0
     add_column :people, :email_verified, :boolean, :default => nil
0
+ if Preference.find(:first).email_verifications?
0
+ # This is to modify the database for the splitting between
0
+ # 'deactivated' and 'email_verified'.
0
+ Person.find(:all).each do |person|
0
+ person.email_verified = !person.deactivated?
0
+ person.save
0
+ end
0
+ end rescue nil
0
   end
0
 
0
   def self.down
...
48
49
50
51
 
 
 
 
 
 
 
 
 
 
52
53
54
...
48
49
50
 
51
52
53
54
55
56
57
58
59
60
61
62
63
0
@@ -48,7 +48,16 @@ describe PeopleController do
0
       @person.toggle!(:deactivated)
0
       get :show, :id => @person
0
       response.should redirect_to(home_url)
0
- flash[:error].should =~ /not activated/
0
+ flash[:error].should =~ /not active/
0
+ end
0
+
0
+ it "should redirect to home for email unverified users" do
0
+ enable_email_notifications
0
+ @person.email_verified = false; @person.save!
0
+ @person.should_not be_active
0
+ get :show, :id => @person
0
+ response.should redirect_to(home_url)
0
+ flash[:error].should =~ /not active/
0
     end
0
   end
0
   

Comments

    No one has commented yet.