Convert isViewer and isAdmin to getters (#6724)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { InferCreationAttributes } from "sequelize";
|
||||
import { UserRole } from "@shared/types";
|
||||
import InviteAcceptedEmail from "@server/emails/templates/InviteAcceptedEmail";
|
||||
import {
|
||||
DomainNotAllowedError,
|
||||
@@ -22,8 +23,8 @@ type Props = {
|
||||
email: string;
|
||||
/** The language of the user, if known */
|
||||
language?: string;
|
||||
/** Provision the new user as an administrator */
|
||||
isAdmin?: boolean;
|
||||
/** The role for new user, Member if none is provided */
|
||||
role?: UserRole;
|
||||
/** The public url of an image representing the user */
|
||||
avatarUrl?: string | null;
|
||||
/**
|
||||
@@ -52,7 +53,7 @@ type Props = {
|
||||
export default async function userProvisioner({
|
||||
name,
|
||||
email,
|
||||
isAdmin,
|
||||
role,
|
||||
language,
|
||||
avatarUrl,
|
||||
teamId,
|
||||
@@ -230,15 +231,12 @@ export default async function userProvisioner({
|
||||
throw DomainNotAllowedError();
|
||||
}
|
||||
|
||||
const defaultUserRole = team?.defaultUserRole;
|
||||
|
||||
const user = await User.create(
|
||||
{
|
||||
name,
|
||||
email,
|
||||
language,
|
||||
isAdmin: typeof isAdmin === "boolean" && isAdmin,
|
||||
isViewer: isAdmin === true ? false : defaultUserRole === "viewer",
|
||||
role: role ?? team?.defaultUserRole,
|
||||
teamId,
|
||||
avatarUrl,
|
||||
authentications: authentication ? [authentication] : [],
|
||||
|
||||
Reference in New Issue
Block a user