abilities()
click to toggle source
def abilities
@abilities ||= Six.new
end
access_denied!()
click to toggle source
def access_denied!
render "errors/access_denied", layout: "errors", status: 404
end
add_project_abilities()
click to toggle source
def add_project_abilities
abilities << Ability
end
after_sign_in_path_for(resource)
click to toggle source
def after_sign_in_path_for resource
if resource.is_a?(User) && resource.respond_to?(:blocked) && resource.blocked
sign_out resource
flash[:alert] = "Your account was blocked"
new_user_session_path
else
super
end
end
authorize_code_access!()
click to toggle source
def authorize_code_access!
return access_denied! unless can?(current_user, :download_code, project)
end
authorize_project!(action)
click to toggle source
def authorize_project!(action)
return access_denied! unless can?(current_user, action, project)
end
can?(object, action, subject)
click to toggle source
def can?(object, action, subject)
abilities.allowed?(object, action, subject)
end
git_not_found!()
click to toggle source
def git_not_found!
render "errors/git_not_found", layout: "errors", status: 404
end
method_missing(method_sym, *arguments, &block)
click to toggle source
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ %r^authorize_(.*)!$/
authorize_project!($1.to_sym)
else
super
end
end
not_found!()
click to toggle source
def not_found!
render "errors/not_found", layout: "errors", status: 404
end
project()
click to toggle source
def project
@project ||= current_user.projects.find_by_code(params[:project_id] || params[:id])
@project || render_404
end
reject_blocked!()
click to toggle source
def reject_blocked!
if current_user && current_user.blocked
sign_out current_user
flash[:alert] = "Your account was blocked"
redirect_to new_user_session_path
end
end
render_404()
click to toggle source
def render_404
render file: Rails.root.join("public", "404"), layout: false, status: "404"
end
require_non_empty_project()
click to toggle source
def require_non_empty_project
redirect_to @project if @project.empty_repo?
end
set_current_user_for_observers()
click to toggle source
def set_current_user_for_observers
MergeRequestObserver.current_user = current_user
IssueObserver.current_user = current_user
end