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

@@ -29,6 +29,7 @@ import type {
IUserResponse,
IUsersState,
CurrentUserResponse,
InvitableRoleName,
} from '@/Interface';
import { getCredentialPermissions } from '@/permissions';
import { getPersonalizedNodeTypes, ROLE } from '@/utils/userUtils';
@@ -302,7 +303,9 @@ export const useUsersStore = defineStore(STORES.USERS, {
const users = await getUsers(rootStore.getRestApiContext);
this.addUsers(users);
},
async inviteUsers(params: Array<{ email: string; role: IRole }>): Promise<IInviteResponse[]> {
async inviteUsers(
params: Array<{ email: string; role: InvitableRoleName }>,
): Promise<IInviteResponse[]> {
const rootStore = useRootStore();
const users = await inviteUsers(rootStore.getRestApiContext, params);
this.addUsers(
@@ -314,11 +317,9 @@ export const useUsersStore = defineStore(STORES.USERS, {
);
return users;
},
async reinviteUser(params: { email: string }): Promise<void> {
async reinviteUser({ email, role }: { email: string; role: InvitableRoleName }): Promise<void> {
const rootStore = useRootStore();
const invitationResponse = await inviteUsers(rootStore.getRestApiContext, [
{ email: params.email },
]);
const invitationResponse = await inviteUsers(rootStore.getRestApiContext, [{ email, role }]);
if (!invitationResponse[0].user.emailSent) {
throw Error(invitationResponse[0].error);
}