1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-12-01 05:43:04 +00:00

only allow organizations to be managed by admins

هذا الالتزام موجود في:
Adam Cooke
2017-04-21 10:18:24 +01:00
الأصل 90b90577cf
التزام 46daca9aa7
10 ملفات معدلة مع 70 إضافات و119 حذوفات

عرض الملف

@@ -1,10 +0,0 @@
class Admin::OrganizationsController < ApplicationController
before_action :admin_required
before_action { params[:id] && @organization = Organization.find_by_permalink!(params[:id]) }
def index
@organizations = Organization.order(:created_at => :desc).includes(:owner).page(params[:page])
end
end

عرض الملف

@@ -1,10 +0,0 @@
class Admin::StatsController < ApplicationController
before_action :admin_required
def stats
@stats = Statistic.global
@queue_size = QueuedMessage.unlocked.retriable.count
end
end

عرض الملف

@@ -1,13 +1,18 @@
class OrganizationsController < ApplicationController
before_action :admin_required, :only => [:new, :create]
before_action :require_organization_admin, :only => [:edit, :update, :delete, :destroy]
def index
if current_user.admin?
@organizations = Organization.present.order(:name).to_a
else
@organizations = current_user.organizations.present.order(:name).to_a
if @organizations.size == 1 && params[:nrd].nil?
redirect_to organization_root_path(@organizations.first)
end
end
end
def new
@organization = Organization.new
@@ -17,7 +22,6 @@ class OrganizationsController < ApplicationController
@organization = Organization.new(params.require(:organization).permit(:name, :permalink))
@organization.owner = current_user
if @organization.save
@organization.users << current_user
redirect_to_with_json organization_root_path(@organization)
else
render_form_errors 'new', @organization

عرض الملف

@@ -1,24 +0,0 @@
- page_title << "Admin"
- page_title << "Organizations"
.pageHeader
%h1.pageHeader__title
%span.pageHeader__titlePrevious Admin &rarr;
Organizations
.pageContent
%table.dataTable
%thead
%tr
%td{:width => "30%"} Name
%td{:width => "25%"} Owner
%td{:width => "5%"} Servers
%td{:width => "10%"} Status
%td{:width => "15%"} Created
%tbody
- for organization in @organizations
%tr
%td= link_to organization.name, organization_root_path(organization), :class => "u-link"
%td= organization.owner&.name || "No Owner"
%td= organization.servers.count
%td= organization.status
%td= organization.created_at.to_s(:long)
= paginate @organizations

عرض الملف

@@ -1,21 +0,0 @@
- page_title << "Admin"
- page_title << "Stats"
.pageContent
.adminStats
%dl.adminStats__stat
%dt Total Messages
%dd= number_with_delimiter @stats.total_messages
%dl.adminStats__stat
%dt Total Outgoing
%dd= number_with_delimiter @stats.total_outgoing
%dl.adminStats__stat
%dt Total Incoming
%dd= number_with_delimiter @stats.total_incoming
%dl.adminStats__stat
%dt Current Queue Size
%dd= number_with_delimiter @queue_size

عرض الملف

@@ -33,13 +33,11 @@
- if organization.admin?(current_user)
%li.siteHeader__subMenuItem= link_to "Organization Settings", organization_settings_path(organization), :class => 'siteHeader__subMenuLink'
%li.siteHeader__subMenuItem= link_to "Manage Users", organization_users_path(organization), :class => 'siteHeader__subMenuLink'
%li.siteHeader__subMenuItem.siteHeader__subMenuItem--div= link_to "Create new organization", :new_organization, :class => 'siteHeader__subMenuLink'
- if current_user.admin?
%li.siteHeader__subMenuItem= link_to "Create new organization", :new_organization, :class => 'siteHeader__subMenuLink'
- if current_user.organizations.present.count > 1
%li.siteHeader__subMenuItem= link_to "Switch organization", root_path, :class => 'siteHeader__subMenuLink'
%li.siteHeader__navItem.siteHeader__navItem--user= current_user.name
- if current_user.admin?
%li.siteHeader__navItem= link_to "Admin", admin_root_path, :class => 'sideHeader__navItemLink'
%li.siteHeader__navItem= link_to "My Settings", settings_path, :class => 'sideHeader__navItemLink'
%li.siteHeader__navItem= link_to "Logout", logout_path, :method => :delete, :class => 'sideHeader__navItemLink'

عرض الملف

@@ -7,12 +7,16 @@
- if @organizations.empty?
.noData.noData--panda.noData--clean
%p.noData__title This is unbearable! You don't have any organizations.
%p.noData__title There are no organizations.
- if current_user.admin?
%p.noData__text
That's not on. You need an organization otherwise you can't do much here. Hit
the button below and you'll be up and running with 10,000 free e-mails before
you know it.
%p.noData__button= link_to "Create your first organization", :new_organization, :class => 'button button--positive'
the button below to create the first organization.
%p.noData__button= link_to "Create the first organization", :new_organization, :class => 'button button--positive'
- else
%p.noData__text
You don't have access to any organizations yet. Ask your administrator to invite
you to some organizations.
- else
%p.pageContent__intro.u-margin
Organizations are entities which are able to deploy mail servers.
@@ -25,4 +29,5 @@
= link_to organization_root_path(organization), :class => 'largeList__link' do
= organization.name
- if current_user.admin?
%p.u-center= link_to "Start another organization", :new_organization, :class => 'button button--positive'

عرض الملف

@@ -8,8 +8,19 @@
= render 'organizations/nav', :active_nav => :users
.pageContent.pageContent--compact
- if @users.empty? && @pending_users.empty?
.noData.noData--penguin.noData--clean
%p.noData__title There are no users assigned to this organization.
%p.noData__text
You add additional users that will be permitted to access this organization.
They will be sent an email and they'll be able to create an account which will
allow them to login and access this organization.
%p.noData__button.buttonSet.buttonSet--center
= link_to "Invite the first user", [:new, organization, :user], :class => 'button button--positive'
- else
%p.pageContent__intro.u-margin
You can share access to your organization with other people by adding them
You can share access to this organization with other people by adding them
here. They'll need to create their own account first and then you'll be able
to add them to your organization by entering their e-mail address.

عرض الملف

@@ -70,12 +70,6 @@ Rails.application.routes.draw do
resources :organizations, :except => [:index]
namespace :admin do
resources :organizations
get 'stats' => 'stats#stats'
root :to => redirect("/admin/organizations")
end
get 'settings' => 'user#edit'
patch 'settings' => 'user#update'
post 'persist' => 'sessions#persist'

عرض الملف

@@ -159,4 +159,8 @@ module Postal
end
end
def self.anonymous_signup?
config.general&.anonymous_signup != false
end
end