Changeset 153 for trunk/examples/blog.rb

Show
Ignore:
Timestamp:
08/31/2006 11:56:08 (2 years ago)
Author:
why
Message:
  • examples/blog.rb: novaa's security fix from #83, thainks!
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/blog.rb

    r149 r153  
    6363        end 
    6464        def post 
    65             post = Post.create :title => input.post_title, :body => input.post_body, 
    66                                :user_id => @state.user_id 
    67             redirect View, post 
     65            unless @state.user_id.blank? 
     66                post = Post.create :title => input.post_title, :body => input.post_body, 
     67                                   :user_id => @state.user_id 
     68                redirect View, post 
     69            end 
    6870        end 
    6971    end 
     
    9799      
    98100        def post 
    99             @post = Post.find input.post_id 
    100             @post.update_attributes :title => input.post_title, :body => input.post_body 
    101             redirect View, @post 
     101            unless @state.user_id.blank? 
     102                @post = Post.find input.post_id 
     103                @post.update_attributes :title => input.post_title, :body => input.post_body 
     104                redirect View, @post 
     105            end 
    102106        end 
    103107    end 
     
    220224          label 'Comment', :for => 'post_body'; br 
    221225          textarea :name => 'post_body' do; end; br 
    222           input :type => 'hidden', :name => 'post_id', :value => post.id 
     226          input :type => 'hidden', :name => 'post_id', :value => @post.id 
    223227          input :type => 'submit' 
    224228        end