add account access
This commit is contained in:
@@ -16,7 +16,7 @@ class UsersController < ApplicationController
|
||||
@users.active.where.not(role: 'integration')
|
||||
end
|
||||
|
||||
@pagy, @users = pagy(@users.where(account: current_account).order(id: :desc))
|
||||
@pagy, @users = pagy(@users.preload(account: :account_accesses).where(account: current_account).order(id: :desc))
|
||||
end
|
||||
|
||||
def new; end
|
||||
|
||||
@@ -33,6 +33,7 @@ class Account < ApplicationRecord
|
||||
has_many :account_linked_accounts, dependent: :destroy
|
||||
has_many :email_events, dependent: :destroy
|
||||
has_many :webhook_urls, dependent: :destroy
|
||||
has_many :account_accesses, dependent: :destroy
|
||||
has_many :account_testing_accounts, -> { testing }, dependent: :destroy,
|
||||
class_name: 'AccountLinkedAccount',
|
||||
inverse_of: :account
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: account_accesses
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint not null
|
||||
# user_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_account_accesses_on_account_id_and_user_id (account_id,user_id) UNIQUE
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (account_id => accounts.id)
|
||||
#
|
||||
class AccountAccess < ApplicationRecord
|
||||
belongs_to :account
|
||||
belongs_to :user
|
||||
end
|
||||
@@ -56,7 +56,7 @@
|
||||
<% if @templates.present? %>
|
||||
<div class="grid gap-4 md:grid-cols-3">
|
||||
<%= render partial: 'templates/template', collection: @templates %>
|
||||
<% if show_dropzone && current_user.created_at > 2.weeks.ago || params[:tour] == 'true' %>
|
||||
<% if show_dropzone && (current_user.created_at > 2.weeks.ago || params[:tour] == 'true') && current_user == true_user %>
|
||||
<% user_config = current_user.user_configs.find_or_initialize_by(key: UserConfig::SHOW_APP_TOUR) %>
|
||||
<% if user_config.new_record? || user_config.value || params[:tour] == 'true' %>
|
||||
<div class="hidden md:block">
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
<%= user.email %>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge badge-info badge-outline">
|
||||
<%= user.role %>
|
||||
<span class="badge badge-info badge-outline whitespace-nowrap">
|
||||
<%= t(user.role) %>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -469,7 +469,9 @@ en: &en
|
||||
upload_initials: Upload Initials
|
||||
draw: Draw
|
||||
upload_signature: Upload Signature
|
||||
integration: Integration
|
||||
admin: Admin
|
||||
tenant_admin: Tenant Admin
|
||||
editor: Editor
|
||||
viewer: Viewer
|
||||
member: Member
|
||||
@@ -1275,7 +1277,9 @@ es: &es
|
||||
upload_initials: Subir iniciales
|
||||
draw: Dibujar
|
||||
upload_signature: Subir firma
|
||||
integration: Integración
|
||||
admin: Administrador
|
||||
tenant_admin: Tenant Administrador
|
||||
editor: Editor
|
||||
viewer: Visor
|
||||
member: Miembro
|
||||
@@ -2080,6 +2084,7 @@ it: &it
|
||||
upload_initials: Carica iniziali
|
||||
draw: Disegna
|
||||
upload_signature: Carica firma
|
||||
integration: Integrazione
|
||||
admin: Amministratore
|
||||
editor: Editor
|
||||
viewer: Visualizzatore
|
||||
@@ -2887,7 +2892,9 @@ fr: &fr
|
||||
upload_initials: Télécharger les initiales
|
||||
draw: Dessiner
|
||||
upload_signature: Télécharger la signature
|
||||
integration: Intégration
|
||||
admin: Administrateur
|
||||
tenant_admin: Tenant Administrateur
|
||||
editor: Éditeur
|
||||
viewer: Lecteur
|
||||
member: Membre
|
||||
@@ -3693,7 +3700,9 @@ pt: &pt
|
||||
upload_initials: Enviar iniciais
|
||||
draw: Desenhar
|
||||
upload_signature: Enviar assinatura
|
||||
integration: Integração
|
||||
admin: Administrador
|
||||
tenant_admin: Tenant Administrador
|
||||
editor: Editor
|
||||
viewer: Visualizador
|
||||
member: Membro
|
||||
@@ -4500,7 +4509,9 @@ de: &de
|
||||
upload_initials: Initialen hochladen
|
||||
draw: Zeichnen
|
||||
upload_signature: Unterschrift hochladen
|
||||
integration: Integration
|
||||
admin: Administrator
|
||||
tenant_admin: Tenant Administrator
|
||||
editor: Redakteur
|
||||
viewer: Betrachter
|
||||
member: Mitglied
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AccountAccesses < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :account_accesses do |t|
|
||||
t.references :account, null: false, foreign_key: true, index: false
|
||||
t.references :user, null: false, foreign_key: false, index: false
|
||||
|
||||
t.index %i[account_id user_id], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
+10
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_02_25_111255) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_05_18_070555) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -24,6 +24,14 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_25_111255) do
|
||||
t.index ["user_id"], name: "index_access_tokens_on_user_id"
|
||||
end
|
||||
|
||||
create_table "account_accesses", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id", "user_id"], name: "index_account_accesses_on_account_id_and_user_id", unique: true
|
||||
end
|
||||
|
||||
create_table "account_configs", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.string "key", null: false
|
||||
@@ -415,6 +423,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_25_111255) do
|
||||
end
|
||||
|
||||
add_foreign_key "access_tokens", "users"
|
||||
add_foreign_key "account_accesses", "accounts"
|
||||
add_foreign_key "account_configs", "accounts"
|
||||
add_foreign_key "account_linked_accounts", "accounts"
|
||||
add_foreign_key "account_linked_accounts", "accounts", column: "linked_account_id"
|
||||
|
||||
Reference in New Issue
Block a user