mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 00:38:35 +00:00
* fix: accept workspace invitations only with the emailed token or a verified email Accepting by id only compared the username with the invited address, which anyone can register without verifying it. The emailed token now proves ownership and verifies the email; without it, the user's email has to be verified. * fix: require a verified email to reject invitations and keep accept visible Rejecting still only checked the username, so whoever registered the invited address could delete the invitation. Accept stays visible after a verification error so it works once the email is verified. * fix: hide accept for unverified users, allow reject, skip the check without SMTP Without an email backend neither the invitation nor a verification email arrives, so the check can't be met. Signing up from the invitation link verifies the email, so the user is signed in even when verification is enforced. * fix: leaving a workspace hangs and removing the current user deletes the wrong workspace
24 lines
642 B
TypeScript
24 lines
642 B
TypeScript
import { getClient } from "../client";
|
|
import { waitForInvitationToken } from "./mail";
|
|
import { User } from "./user";
|
|
import { Workspace } from "./workspace";
|
|
|
|
export async function addWorkspaceMember(
|
|
owner: User,
|
|
workspace: Workspace,
|
|
member: User,
|
|
permissions: string,
|
|
): Promise<void> {
|
|
const inviteResponse: any = await getClient(owner).post(
|
|
`workspaces/invitations/workspace/${workspace.id}/`,
|
|
{
|
|
email: member.email,
|
|
permissions,
|
|
},
|
|
);
|
|
await getClient(member).post(
|
|
`workspaces/invitations/${inviteResponse.data.id}/accept/`,
|
|
{ token: await waitForInvitationToken(member.email) },
|
|
);
|
|
}
|