enhanced password checking behavior in remove_orphaned_pages;

extracted password error to application
This commit is contained in:
Alexey Verkhovsky 2005-02-05 13:34:12 +00:00
parent 8b21b8286f
commit bc97b8d4f7
3 changed files with 14 additions and 8 deletions

View file

@ -44,9 +44,10 @@ class AdminController < ApplicationController
end end
def edit_web def edit_web
if @params['system_password'] system_password = @params['system_password']
if system_password
# form submitted # form submitted
if wiki.authenticate(@params['system_password']) if wiki.authenticate(system_password)
wiki.edit_web( wiki.edit_web(
@web.address, @params['address'], @params['name'], @web.address, @params['address'], @params['name'],
@params['markup'].intern, @params['markup'].intern,
@ -61,11 +62,7 @@ class AdminController < ApplicationController
) )
redirect_show('HomePage', @params['address']) redirect_show('HomePage', @params['address'])
else else
if @params['system_password'].empty? flash[:error] = password_error(system_password)
flash[:error] = 'Please enter the system password'
else
flash[:error] = 'You entered a wrong system password. Please enter the right one'
end
# and re-render the same template again # and re-render the same template again
end end
else else

View file

@ -71,6 +71,14 @@ class ApplicationController < ActionController::Base
not @web_name.nil? not @web_name.nil?
end end
def password_error(password)
if password.nil? or password.empty?
'Please enter the password.'
else
'You entered a wrong password. Please enter the right one.'
end
end
def redirect_show(page_name = @page_name, web = @web_name) def redirect_show(page_name = @page_name, web = @web_name)
redirect_to :web => web, :controller => 'wiki', :action => 'show', redirect_to :web => web, :controller => 'wiki', :action => 'show',
:id => CGI.escape(page_name || 'HomePage') :id => CGI.escape(page_name || 'HomePage')

View file

@ -93,7 +93,8 @@ class WikiController < ApplicationController
wiki.remove_orphaned_pages(@web_name) wiki.remove_orphaned_pages(@web_name)
redirect_to :action => 'list' redirect_to :action => 'list'
else else
redirect_show 'HomePage' flash[:error] = password_error(@params['system_password'])
return_to_last_remembered
end end
end end