feat(API): Implement users account quota guards (#6434)
* feat(cli): Implement users account quota guards Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Remove comment Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Address PR comments - Getting `usersQuota` from `Settings` repo - Revert `isUserManagementEnabled` helper - Fix FE listing of users Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Refactor isWithinUserQuota getter and fix tests Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Revert testDb.ts changes Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Cleanup & improve types Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Fix duplicated method * Fix failing test * Remove `isUserManagementEnabled` completely Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Check for globalRole.name to determine if user is owner Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Fix unit tests Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Set isInstanceOwnerSetUp in specs * Fix SettingsUserView UM Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * refactor: License typings suggestions for users quota guards (#6636) refactor: License typings suggestions * Update packages/cli/src/Ldap/helpers.ts Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Update packages/cli/test/integration/shared/utils.ts Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Address PR comments Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Use 403 for all user quota related errors Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> --------- Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
</template>
|
||||
<div>
|
||||
<n8n-button
|
||||
:disabled="ssoStore.isSamlLoginEnabled"
|
||||
:disabled="ssoStore.isSamlLoginEnabled || !settingsStore.isBelowUserQuota"
|
||||
:label="$locale.baseText('settings.users.invite')"
|
||||
@click="onInvite"
|
||||
size="large"
|
||||
@@ -19,17 +19,28 @@
|
||||
</n8n-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="usersStore.showUMSetupWarning" :class="$style.setupInfoContainer">
|
||||
<div v-if="!settingsStore.isBelowUserQuota" :class="$style.setupInfoContainer">
|
||||
<n8n-action-box
|
||||
:heading="$locale.baseText('settings.users.setupToInviteUsers')"
|
||||
:buttonText="$locale.baseText('settings.users.setupMyAccount')"
|
||||
:description="`${
|
||||
isSharingEnabled ? '' : $locale.baseText('settings.users.setupToInviteUsersInfo')
|
||||
}`"
|
||||
@click="redirectToSetup"
|
||||
:heading="
|
||||
$locale.baseText(uiStore.contextBasedTranslationKeys.users.settings.unavailable.title)
|
||||
"
|
||||
:description="
|
||||
$locale.baseText(
|
||||
uiStore.contextBasedTranslationKeys.users.settings.unavailable.description,
|
||||
)
|
||||
"
|
||||
:buttonText="
|
||||
$locale.baseText(uiStore.contextBasedTranslationKeys.users.settings.unavailable.button)
|
||||
"
|
||||
@click="goToUpgrade"
|
||||
/>
|
||||
</div>
|
||||
<div :class="$style.usersContainer" v-else>
|
||||
<!-- If there's more than 1 user it means the account quota was more than 1 in the past. So we need to allow instance owner to be able to delete users and transfer workflows.
|
||||
-->
|
||||
<div
|
||||
:class="$style.usersContainer"
|
||||
v-if="settingsStore.isBelowUserQuota || usersStore.allUsers.length > 1"
|
||||
>
|
||||
<n8n-users-list
|
||||
:actions="usersListActions"
|
||||
:users="usersStore.allUsers"
|
||||
@@ -43,6 +54,19 @@
|
||||
@disallowSSOManualLogin="onDisallowSSOManualLogin"
|
||||
/>
|
||||
</div>
|
||||
<n8n-action-box
|
||||
v-else
|
||||
:heading="
|
||||
$locale.baseText(uiStore.contextBasedTranslationKeys.users.settings.unavailable.title)
|
||||
"
|
||||
:description="
|
||||
$locale.baseText(uiStore.contextBasedTranslationKeys.users.settings.unavailable.description)
|
||||
"
|
||||
:buttonText="
|
||||
$locale.baseText(uiStore.contextBasedTranslationKeys.users.settings.unavailable.button)
|
||||
"
|
||||
@click="goToUpgrade"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -83,12 +107,16 @@ export default defineComponent({
|
||||
{
|
||||
label: this.$locale.baseText('settings.users.actions.copyInviteLink'),
|
||||
value: 'copyInviteLink',
|
||||
guard: (user) => !user.firstName && !!user.inviteAcceptUrl,
|
||||
guard: (user) =>
|
||||
this.settingsStore.isBelowUserQuota && !user.firstName && !!user.inviteAcceptUrl,
|
||||
},
|
||||
{
|
||||
label: this.$locale.baseText('settings.users.actions.reinvite'),
|
||||
value: 'reinvite',
|
||||
guard: (user) => !user.firstName && this.settingsStore.isSmtpSetup,
|
||||
guard: (user) =>
|
||||
this.settingsStore.isBelowUserQuota &&
|
||||
!user.firstName &&
|
||||
this.settingsStore.isSmtpSetup,
|
||||
},
|
||||
{
|
||||
label: this.$locale.baseText('settings.users.actions.delete'),
|
||||
@@ -97,6 +125,7 @@ export default defineComponent({
|
||||
{
|
||||
label: this.$locale.baseText('settings.users.actions.copyPasswordResetLink'),
|
||||
value: 'copyPasswordResetLink',
|
||||
guard: () => this.settingsStore.isBelowUserQuota,
|
||||
},
|
||||
{
|
||||
label: this.$locale.baseText('settings.users.actions.allowSSOManualLogin'),
|
||||
|
||||
Reference in New Issue
Block a user