2014-06-07 08:06:55 -04:00
|
|
|
class NamespacesController < ApplicationController
|
2015-04-16 08:03:37 -04:00
|
|
|
skip_before_action :authenticate_user!
|
2014-06-07 08:06:55 -04:00
|
|
|
|
|
|
|
def show
|
|
|
|
namespace = Namespace.find_by(path: params[:id])
|
|
|
|
|
2015-03-24 10:55:12 -04:00
|
|
|
if namespace
|
|
|
|
if namespace.is_a?(Group)
|
|
|
|
group = namespace
|
|
|
|
else
|
|
|
|
user = namespace.owner
|
|
|
|
end
|
2014-06-07 08:06:55 -04:00
|
|
|
end
|
|
|
|
|
2015-03-24 10:55:12 -04:00
|
|
|
if user
|
|
|
|
redirect_to user_path(user)
|
2016-03-08 19:01:33 -05:00
|
|
|
elsif group && can?(current_user, :read_group, namespace)
|
2015-03-24 10:55:12 -04:00
|
|
|
redirect_to group_path(group)
|
|
|
|
elsif current_user.nil?
|
|
|
|
authenticate_user!
|
2014-06-07 08:06:55 -04:00
|
|
|
else
|
2015-03-24 10:55:12 -04:00
|
|
|
render_404
|
2014-06-07 08:06:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|