Defect #4446 ยป and_return.patch
app/controllers/account_controller.rb | ||
---|---|---|
67 | 67 |
if request.post? |
68 | 68 |
user = User.find_by_mail(params[:mail]) |
69 | 69 |
# user not found in db |
70 |
flash.now[:error] = l(:notice_account_unknown_email) and return unless user
|
|
70 |
(flash.now[:error] = l(:notice_account_unknown_email); return) unless user
|
|
71 | 71 |
# user uses an external authentification |
72 |
flash.now[:error] = l(:notice_can_t_change_password) and return if user.auth_source_id
|
|
72 |
(flash.now[:error] = l(:notice_can_t_change_password); return) if user.auth_source_id
|
|
73 | 73 |
# create a new token for password recovery |
74 | 74 |
token = Token.new(:user => user, :action => "recovery") |
75 | 75 |
if token.save |
app/controllers/application_controller.rb | ||
---|---|---|
30 | 30 |
def delete_broken_cookies |
31 | 31 |
if cookies['_redmine_session'] && cookies['_redmine_session'] !~ /--/ |
32 | 32 |
cookies.delete '_redmine_session' |
33 |
redirect_to home_path and return false |
|
33 |
redirect_to home_path |
|
34 |
return false |
|
34 | 35 |
end |
35 | 36 |
end |
36 | 37 |
|
... | ... | |
166 | 167 |
uri = URI.parse(back_url) |
167 | 168 |
# do not redirect user to another host or to the login or register page |
168 | 169 |
if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) |
169 |
redirect_to(back_url) and return |
|
170 |
redirect_to(back_url) |
|
171 |
return |
|
170 | 172 |
end |
171 | 173 |
rescue URI::InvalidURIError |
172 | 174 |
# redirect to default |
app/controllers/custom_fields_controller.rb | ||
---|---|---|
32 | 32 |
end |
33 | 33 |
rescue |
34 | 34 |
end |
35 |
redirect_to(:action => 'index') and return unless @custom_field.is_a?(CustomField)
|
|
35 |
(redirect_to(:action => 'index'); return) unless @custom_field.is_a?(CustomField)
|
|
36 | 36 |
|
37 | 37 |
if request.post? and @custom_field.save |
38 | 38 |
flash[:notice] = l(:notice_successful_create) |
app/controllers/issues_controller.rb | ||
---|---|---|
475 | 475 |
@project = projects.first |
476 | 476 |
else |
477 | 477 |
# TODO: let users bulk edit/move/destroy issues from different projects |
478 |
render_error 'Can not bulk edit/move/destroy issues from different projects' and return false |
|
478 |
render_error 'Can not bulk edit/move/destroy issues from different projects' |
|
479 |
return false |
|
479 | 480 |
end |
480 | 481 |
rescue ActiveRecord::RecordNotFound |
481 | 482 |
render_404 |
app/controllers/journals_controller.rb | ||
---|---|---|
33 | 33 |
private |
34 | 34 |
def find_journal |
35 | 35 |
@journal = Journal.find(params[:id]) |
36 |
render_403 and return false unless @journal.editable_by?(User.current)
|
|
36 |
(render_403; return false) unless @journal.editable_by?(User.current)
|
|
37 | 37 |
@project = @journal.journalized.project |
38 | 38 |
rescue ActiveRecord::RecordNotFound |
39 | 39 |
render_404 |
app/controllers/messages_controller.rb | ||
---|---|---|
68 | 68 | |
69 | 69 |
# Edit a message |
70 | 70 |
def edit |
71 |
render_403 and return false unless @message.editable_by?(User.current)
|
|
71 |
(render_403; return false) unless @message.editable_by?(User.current)
|
|
72 | 72 |
if params[:message] |
73 | 73 |
@message.locked = params[:message]['locked'] |
74 | 74 |
@message.sticky = params[:message]['sticky'] |
... | ... | |
83 | 83 |
|
84 | 84 |
# Delete a messages |
85 | 85 |
def destroy |
86 |
render_403 and return false unless @message.destroyable_by?(User.current)
|
|
86 |
(render_403; return false) unless @message.destroyable_by?(User.current)
|
|
87 | 87 |
@message.destroy |
88 | 88 |
redirect_to @message.parent.nil? ? |
89 | 89 |
{ :controller => 'boards', :action => 'show', :project_id => @project, :id => @board } : |
app/controllers/my_controller.rb | ||
---|---|---|
78 | 78 |
# Manage user's password |
79 | 79 |
def password |
80 | 80 |
@user = User.current |
81 |
flash[:error] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id |
|
81 |
if @user.auth_source_id |
|
82 |
flash[:error] = l(:notice_can_t_change_password) |
|
83 |
redirect_to :action => 'account' |
|
84 |
return |
|
85 |
end |
|
82 | 86 |
if request.post? |
83 | 87 |
if @user.check_password?(params[:password]) |
84 | 88 |
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] |
... | ... | |
116 | 120 |
# params[:block] : id of the block to add |
117 | 121 |
def add_block |
118 | 122 |
block = params[:block].to_s.underscore |
119 |
render(:nothing => true) and return unless block && (BLOCKS.keys.include? block)
|
|
123 |
(render :nothing => true; return) unless block && (BLOCKS.keys.include? block)
|
|
120 | 124 |
@user = User.current |
121 | 125 |
# remove if already present in a group |
122 | 126 |
%w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } |
app/controllers/repositories_controller.rb | ||
---|---|---|
73 | 73 |
if request.xhr? |
74 | 74 |
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true) |
75 | 75 |
else |
76 |
show_error_not_found and return unless @entries
|
|
76 |
(show_error_not_found; return) unless @entries
|
|
77 | 77 |
@changesets = @repository.latest_changesets(@path, @rev) |
78 | 78 |
@properties = @repository.properties(@path, @rev) |
79 | 79 |
render :action => 'show' |
... | ... | |
84 | 84 |
|
85 | 85 |
def changes |
86 | 86 |
@entry = @repository.entry(@path, @rev) |
87 |
show_error_not_found and return unless @entry
|
|
87 |
(show_error_not_found; return) unless @entry
|
|
88 | 88 |
@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) |
89 | 89 |
@properties = @repository.properties(@path, @rev) |
90 | 90 |
end |
... | ... | |
107 | 107 |
|
108 | 108 |
def entry |
109 | 109 |
@entry = @repository.entry(@path, @rev) |
110 |
show_error_not_found and return unless @entry
|
|
111 |
|
|
110 |
(show_error_not_found; return) unless @entry
|
|
111 | ||
112 | 112 |
# If the entry is a dir, show the browser |
113 |
show and return if @entry.is_dir?
|
|
114 |
|
|
113 |
(show; return) if @entry.is_dir?
|
|
114 | ||
115 | 115 |
@content = @repository.cat(@path, @rev) |
116 |
show_error_not_found and return unless @content
|
|
116 |
(show_error_not_found; return) unless @content
|
|
117 | 117 |
if 'raw' == params[:format] || @content.is_binary_data? || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte) |
118 | 118 |
# Force the download |
119 | 119 |
send_data @content, :filename => @path.split('/').last |
... | ... | |
125 | 125 |
|
126 | 126 |
def annotate |
127 | 127 |
@entry = @repository.entry(@path, @rev) |
128 |
show_error_not_found and return unless @entry
|
|
128 |
(show_error_not_found; return) unless @entry
|
|
129 | 129 |
|
130 | 130 |
@annotate = @repository.scm.annotate(@path, @rev) |
131 |
render_error l(:error_scm_annotate) and return if @annotate.nil? || @annotate.empty?
|
|
131 |
(render_error l(:error_scm_annotate); return) if @annotate.nil? || @annotate.empty?
|
|
132 | 132 |
end |
133 | 133 |
|
134 | 134 |
def revision |
... | ... | |
146 | 146 |
def diff |
147 | 147 |
if params[:format] == 'diff' |
148 | 148 |
@diff = @repository.diff(@path, @rev, @rev_to) |
149 |
show_error_not_found and return unless @diff
|
|
149 |
(show_error_not_found; return) unless @diff
|
|
150 | 150 |
filename = "changeset_r#{@rev}" |
151 | 151 |
filename << "_r#{@rev_to}" if @rev_to |
152 | 152 |
send_data @diff.join, :filename => "#{filename}.diff", |
... | ... | |
199 | 199 |
def find_repository |
200 | 200 |
@project = Project.find(params[:id]) |
201 | 201 |
@repository = @project.repository |
202 |
render_404 and return false unless @repository
|
|
202 |
(render_404; return false) unless @repository
|
|
203 | 203 |
@path = params[:path].join('/') unless params[:path].nil? |
204 | 204 |
@path ||= '' |
205 | 205 |
@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip |
app/controllers/timelog_controller.rb | ||
---|---|---|
209 | 209 |
end |
210 | 210 |
|
211 | 211 |
def edit |
212 |
render_403 and return if @time_entry && !@time_entry.editable_by?(User.current)
|
|
212 |
(render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)
|
|
213 | 213 |
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today) |
214 | 214 |
@time_entry.attributes = params[:time_entry] |
215 | 215 |
|
... | ... | |
223 | 223 |
end |
224 | 224 |
|
225 | 225 |
def destroy |
226 |
render_404 and return unless @time_entry
|
|
227 |
render_403 and return unless @time_entry.editable_by?(User.current)
|
|
226 |
(render_404; return) unless @time_entry
|
|
227 |
(render_403; return) unless @time_entry.editable_by?(User.current)
|
|
228 | 228 |
@time_entry.destroy |
229 | 229 |
flash[:notice] = l(:notice_successful_delete) |
230 | 230 |
redirect_to :back |
app/controllers/users_controller.rb | ||
---|---|---|
62 | 62 |
@events_by_day = events.group_by(&:event_date) |
63 | 63 |
|
64 | 64 |
if @user != User.current && !User.current.admin? && @memberships.empty? && events.empty? |
65 |
render_404 and return |
|
65 |
render_404 |
|
66 |
return |
|
66 | 67 |
end |
67 | 68 |
render :layout => 'base' |
68 | 69 |
app/controllers/wiki_controller.rb | ||
---|---|---|
183 | 183 |
return |
184 | 184 |
else |
185 | 185 |
# requested special page doesn't exist, redirect to default page |
186 |
redirect_to :action => 'index', :id => @project, :page => nil and return |
|
186 |
redirect_to :action => 'index', :id => @project, :page => nil |
|
187 |
return |
|
187 | 188 |
end |
188 | 189 |
render :action => "special_#{page_title}" |
189 | 190 |
end |