summaryrefslogtreecommitdiff
path: root/app/controllers/namespaces_controller.rb
blob: 5a94dcb0dbda623f540ddf128c0e1d25c9829bf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class NamespacesController < ApplicationController
  skip_before_action :authenticate_user!

  def show
    namespace = Namespace.find_by(path: params[:id])

    if namespace
      if namespace.is_a?(Group)
        group = namespace
      else
        user = namespace.owner
      end
    end

    if user
      redirect_to user_path(user)
    elsif group && can?(current_user, :read_group, namespace)
      redirect_to group_path(group)
    elsif current_user.nil?
      authenticate_user!
    else
      render_404
    end
  end
end