gitlab-org--gitlab-foss/app/controllers/users_controller.rb
Ciro Santillli 91571c078d User pages are visible to users without login
... if the user is authorized to at least one public project.
2014-02-11 15:45:30 +01:00

23 lines
623 B
Ruby

class UsersController < ApplicationController
skip_before_filter :authenticate_user!, only: [:show]
layout :determine_layout
def show
@user = User.find_by_username!(params[:username])
@projects = @user.authorized_projects.includes(:namespace).select {|project| can?(current_user, :read_project, project)}
if !current_user && @projects.empty?
return authenticate_user!
end
@events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
@title = @user.name
end
def determine_layout
if current_user
'navless'
else
'public_users'
end
end
end