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)
|
|
|
|
elsif group && can?(current_user, :read_group, group)
|
|
|
|
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
|