1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +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,11 +1,16 @@
class OrganizationsController < ApplicationController class OrganizationsController < ApplicationController
before_action :admin_required, :only => [:new, :create]
before_action :require_organization_admin, :only => [:edit, :update, :delete, :destroy] before_action :require_organization_admin, :only => [:edit, :update, :delete, :destroy]
def index def index
@organizations = current_user.organizations.present.order(:name).to_a if current_user.admin?
if @organizations.size == 1 && params[:nrd].nil? @organizations = Organization.present.order(:name).to_a
redirect_to organization_root_path(@organizations.first) 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
end end
@@ -17,7 +22,6 @@ class OrganizationsController < ApplicationController
@organization = Organization.new(params.require(:organization).permit(:name, :permalink)) @organization = Organization.new(params.require(:organization).permit(:name, :permalink))
@organization.owner = current_user @organization.owner = current_user
if @organization.save if @organization.save
@organization.users << current_user
redirect_to_with_json organization_root_path(@organization) redirect_to_with_json organization_root_path(@organization)
else else
render_form_errors 'new', @organization 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) - if organization.admin?(current_user)
%li.siteHeader__subMenuItem= link_to "Organization Settings", organization_settings_path(organization), :class => 'siteHeader__subMenuLink' %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= link_to "Manage Users", organization_users_path(organization), :class => 'siteHeader__subMenuLink'
- if current_user.admin?
%li.siteHeader__subMenuItem.siteHeader__subMenuItem--div= link_to "Create new organization", :new_organization, :class => 'siteHeader__subMenuLink' %li.siteHeader__subMenuItem= link_to "Create new organization", :new_organization, :class => 'siteHeader__subMenuLink'
- if current_user.organizations.present.count > 1 - if current_user.organizations.present.count > 1
%li.siteHeader__subMenuItem= link_to "Switch organization", root_path, :class => 'siteHeader__subMenuLink' %li.siteHeader__subMenuItem= link_to "Switch organization", root_path, :class => 'siteHeader__subMenuLink'
%li.siteHeader__navItem.siteHeader__navItem--user= current_user.name %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 "My Settings", settings_path, :class => 'sideHeader__navItemLink'
%li.siteHeader__navItem= link_to "Logout", logout_path, :method => :delete, :class => 'sideHeader__navItemLink' %li.siteHeader__navItem= link_to "Logout", logout_path, :method => :delete, :class => 'sideHeader__navItemLink'

عرض الملف

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

عرض الملف

@@ -8,39 +8,50 @@
= render 'organizations/nav', :active_nav => :users = render 'organizations/nav', :active_nav => :users
.pageContent.pageContent--compact .pageContent.pageContent--compact
%p.pageContent__intro.u-margin - if @users.empty? && @pending_users.empty?
You can share access to your organization with other people by adding them .noData.noData--penguin.noData--clean
here. They'll need to create their own account first and then you'll be able %p.noData__title There are no users assigned to this organization.
to add them to your organization by entering their e-mail address. %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'
%ul.userList.u-margin - else
- for user in @users %p.pageContent__intro.u-margin
%li.userList__item You can share access to this organization with other people by adding them
= image_tag user.user.avatar_url, :class => 'userList__avatar' here. They'll need to create their own account first and then you'll be able
.userList__details to add them to your organization by entering their e-mail address.
%p.userList__name
= user.user.name %ul.userList.u-margin
- if user.user == organization.owner - for user in @users
%span.userList__owner.label Owner %li.userList__item
- elsif user.admin? = image_tag user.user.avatar_url, :class => 'userList__avatar'
%span.userList__admin.label Admin .userList__details
%p.userList__email= user.user.email_address %p.userList__name
%ul.userList__actions = user.user.name
- if organization.owner != user.user - if user.user == organization.owner
%li= link_to "Edit permissions", [:edit, organization, user.user] %span.userList__owner.label Owner
- if organization.owner == current_user - elsif user.admin?
%li= link_to "Make owner", [:make_owner, organization, user.user], :method => :post, :data => {:confirm => "Are you sure you wish to make #{user.user.name} the owner of this organization? They will be granted full admin access. You won't be able to change this back.", :disable_with => "Promoting..."}, :remote => true %span.userList__admin.label Admin
%li= link_to "Revoke access", [organization, user.user], :method => :delete, :data => {:confirm => "Are you sure you wish to revoke #{user.user.name}'s access to the organization?", :disable_with => "Deleting..."}, :remote => true, :class => 'userList__revoke' %p.userList__email= user.user.email_address
- for user in @pending_users %ul.userList__actions
%li.userList__item - if organization.owner != user.user
= image_tag user.user.avatar_url, :class => 'userList__avatar' %li= link_to "Edit permissions", [:edit, organization, user.user]
.userList__details - if organization.owner == current_user
%p.userList__name %li= link_to "Make owner", [:make_owner, organization, user.user], :method => :post, :data => {:confirm => "Are you sure you wish to make #{user.user.name} the owner of this organization? They will be granted full admin access. You won't be able to change this back.", :disable_with => "Promoting..."}, :remote => true
= user.user.email_address %li= link_to "Revoke access", [organization, user.user], :method => :delete, :data => {:confirm => "Are you sure you wish to revoke #{user.user.name}'s access to the organization?", :disable_with => "Deleting..."}, :remote => true, :class => 'userList__revoke'
%span.userList__pending.label Pending - for user in @pending_users
%ul.userList__actions %li.userList__item
%li= link_to "Edit permissions", edit_organization_user_path(organization, user.user, :invite => 1) = image_tag user.user.avatar_url, :class => 'userList__avatar'
%li= link_to "Cancel invitation", organization_user_path(organization, user.user, :invite => 1), :method => :delete, :data => {:confirm => "Are you sure you wish to cancel this invitation?", :disable_with => "Deleting..."}, :remote => true, :class => 'userList__revoke' .userList__details
%p.userList__name
= user.user.email_address
%span.userList__pending.label Pending
%ul.userList__actions
%li= link_to "Edit permissions", edit_organization_user_path(organization, user.user, :invite => 1)
%li= link_to "Cancel invitation", organization_user_path(organization, user.user, :invite => 1), :method => :delete, :data => {:confirm => "Are you sure you wish to cancel this invitation?", :disable_with => "Deleting..."}, :remote => true, :class => 'userList__revoke'
%p.u-center= link_to "Invite a new user", [:new, organization, :user], :class => 'button button--positive' %p.u-center= link_to "Invite a new user", [:new, organization, :user], :class => 'button button--positive'

عرض الملف

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

عرض الملف

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