Improved behavior of JavaScript in the author field [from I2 patch by court3nay]

This commit is contained in:
Alexey Verkhovsky 2005-11-04 05:23:34 +00:00
parent 35b77f6440
commit dea8d70c48
6 changed files with 28 additions and 39 deletions

View file

@ -2,7 +2,7 @@
# Likewise will all the methods added be available for all controllers.
class ApplicationController < ActionController::Base
before_filter :connect_to_model, :setup_url_generator, :set_content_type_header, :set_robots_metatag
before_filter :connect_to_model, :check_authorization, :setup_url_generator, :set_content_type_header, :set_robots_metatag
after_filter :remember_location, :teardown_url_generator
# For injecting a different wiki model implementation. Intended for use in tests
@ -20,15 +20,8 @@ class ApplicationController < ActionController::Base
protected
def authorized?
@web.nil? ||
@web.password.nil? ||
cookies['web_address'] == @web.password ||
password_check(@params['password'])
end
def check_authorization
if in_a_web? and authorization_needed? and not authorized? and
if in_a_web? and authorization_needed? and not authorized?
redirect_to :controller => 'wiki', :action => 'login', :web => @web_name
return false
end
@ -41,14 +34,13 @@ class ApplicationController < ActionController::Base
if @web_name
@web = @wiki.webs[@web_name]
if @web.nil?
render_text "Unknown web '#{@web_name}'", '404 Not Found'
render :status => 404, :text => "Unknown web '#{@web_name}'"
return false
end
end
@page_name = @file_name = @params['id']
@page = @wiki.read_page(@web_name, @page_name) unless @page_name.nil?
@author = cookies['author'] || 'AnonymousCoward'
check_authorization
end
FILE_TYPES = {
@ -67,10 +59,6 @@ class ApplicationController < ActionController::Base
super(file, options)
end
def in_a_web?
not @web_name.nil?
end
def password_check(password)
if password == @web.password
cookies['web_address'] = password
@ -168,8 +156,20 @@ class ApplicationController < ActionController::Base
self.class.wiki
end
private
def in_a_web?
not @web_name.nil?
end
def authorization_needed?
not %w( login authenticate published rss_with_content rss_with_headlines ).include?(action_name)
end
def authorized?
@web.password.nil? or
cookies['web_address'] == @web.password or
password_check(@params['password'])
end
end