fix: Fix user reinvites on FE and BE (#8261)

This commit is contained in:
Iván Ovejero
2024-01-09 13:52:34 +01:00
committed by GitHub
parent b1c1372bc2
commit 0dabe5c74e
7 changed files with 50 additions and 13 deletions

View File

@@ -89,7 +89,7 @@ import { defineComponent } from 'vue';
import { mapStores } from 'pinia';
import { EnterpriseEditionFeature, INVITE_USER_MODAL_KEY, VIEWS } from '@/constants';
import type { IUser, IUserListAction } from '@/Interface';
import type { IUser, IUserListAction, InvitableRoleName } from '@/Interface';
import { useToast } from '@/composables/useToast';
import { useUIStore } from '@/stores/ui.store';
import { useSettingsStore } from '@/stores/settings.store';
@@ -207,9 +207,15 @@ export default defineComponent({
},
async onReinvite(userId: string) {
const user = this.usersStore.getUserById(userId);
if (user?.email) {
if (user?.email && user?.globalRole) {
if (!['admin', 'member'].includes(user.globalRole.name)) {
throw new Error('Invalid role name on reinvite');
}
try {
await this.usersStore.reinviteUser({ email: user.email });
await this.usersStore.reinviteUser({
email: user.email,
role: user.globalRole.name as InvitableRoleName,
});
this.showToast({
type: 'success',
title: this.$locale.baseText('settings.users.inviteResent'),