enhanced password checking behavior in remove_orphaned_pages;
extracted password error to application
This commit is contained in:
parent
8b21b8286f
commit
bc97b8d4f7
|
@ -44,9 +44,10 @@ class AdminController < ApplicationController
|
|||
end
|
||||
|
||||
def edit_web
|
||||
if @params['system_password']
|
||||
system_password = @params['system_password']
|
||||
if system_password
|
||||
# form submitted
|
||||
if wiki.authenticate(@params['system_password'])
|
||||
if wiki.authenticate(system_password)
|
||||
wiki.edit_web(
|
||||
@web.address, @params['address'], @params['name'],
|
||||
@params['markup'].intern,
|
||||
|
@ -61,11 +62,7 @@ class AdminController < ApplicationController
|
|||
)
|
||||
redirect_show('HomePage', @params['address'])
|
||||
else
|
||||
if @params['system_password'].empty?
|
||||
flash[:error] = 'Please enter the system password'
|
||||
else
|
||||
flash[:error] = 'You entered a wrong system password. Please enter the right one'
|
||||
end
|
||||
flash[:error] = password_error(system_password)
|
||||
# and re-render the same template again
|
||||
end
|
||||
else
|
||||
|
|
|
@ -71,6 +71,14 @@ class ApplicationController < ActionController::Base
|
|||
not @web_name.nil?
|
||||
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)
|
||||
redirect_to :web => web, :controller => 'wiki', :action => 'show',
|
||||
:id => CGI.escape(page_name || 'HomePage')
|
||||
|
|
|
@ -93,7 +93,8 @@ class WikiController < ApplicationController
|
|||
wiki.remove_orphaned_pages(@web_name)
|
||||
redirect_to :action => 'list'
|
||||
else
|
||||
redirect_show 'HomePage'
|
||||
flash[:error] = password_error(@params['system_password'])
|
||||
return_to_last_remembered
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue