feat: API org user scope (#15739)

* Init organizations users GET endpoint

* Fix get users endpoint

* Add create user input

* Add POST to organization user endpoint

* Creating a user make email mandatory

* Move DTOs out of platform types

* Use plainToInstance for data filtering

* POST create user and org membership

* Add email check

* Filter update user call

* Add getOrg decorator to endpoints

* Add update endpoint

* Add delete endpoint

* Fix merge changes to create new org user

* Init tests

* Send org signup email

* Abstract username check

* Implement email service

* WIP E2E test

* Rename methods

* Update update org user DTO

* Remove unused inputs

* chore: add ApiProperty decorator to users class validators

* Type fix

* Update tests

* chore: code review comments

* chore: code review comments

* chore: code review comments

---------

Co-authored-by: Morgan Vernay <[email protected]>
Co-authored-by: Morgan <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-07-16 10:50:46 +00:00
1 parent 9fec77e345
commit 41cde8e384
23 files changed
+1743 -3

No files matched your search

@@ -0,0 +1,131 @@
import { ApiProperty } from "@nestjs/swagger";
import { Expose, Transform } from "class-transformer";
import {
IsBoolean,
IsEmail,
IsHexColor,
IsNumber,
IsOptional,
IsString,
Validate,
Min,
} from "class-validator";
import { AvatarValidator } from "../validators/avatarValidator";
import { LocaleValidator } from "../validators/localeValidator";
import { ThemeValidator } from "../validators/themeValidator";
import { TimeFormatValidator } from "../validators/timeFormatValidator";
import { TimeZoneValidator } from "../validators/timeZoneValidator";
import { WeekdayValidator } from "../validators/weekdayValidator";
export class CreateUserInput {
@ApiProperty({ type: String, description: "User email address", example: "[email protected]" })
@IsEmail()
@Transform(({ value }) => {
if (typeof value === "string") {
return value.toLowerCase();
}
})
@Expose()
email!: string;
@ApiProperty({ type: String, required: false, description: "Username", example: "user123" })
@IsOptional()
@IsString()
@Transform(({ value }) => {
if (typeof value === "string") {
return value.toLowerCase();
}
})
@Expose()
username?: string;
@ApiProperty({ type: String, required: false, description: "Preferred weekday", example: "Monday" })
@IsOptional()
@IsString()
@Validate(WeekdayValidator)
@Expose()
weekday?: string;
@ApiProperty({
type: String,
required: false,
description: "Brand color in HEX format",
example: "#FFFFFF",
})
@IsOptional()
@IsHexColor()
@Expose()
brandColor?: string;
@ApiProperty({
type: String,
required: false,
description: "Dark brand color in HEX format",
example: "#000000",
})
@IsOptional()
@IsHexColor()
@Expose()
darkBrandColor?: string;
@ApiProperty({ type: Boolean, required: false, description: "Hide branding", example: false })
@IsOptional()
@IsBoolean()
@Expose()
hideBranding?: boolean;
@ApiProperty({ type: String, required: false, description: "Time zone", example: "America/New_York" })
@IsOptional()
@IsString()
@Validate(TimeZoneValidator)
@Expose()
timeZone?: string;
@ApiProperty({ type: String, required: false, description: "Theme", example: "dark" })
@IsOptional()
@IsString()
@Validate(ThemeValidator)
@Expose()
theme?: string | null;
@ApiProperty({ type: String, required: false, description: "Application theme", example: "light" })
@IsOptional()
@IsString()
@Validate(ThemeValidator)
@Expose()
appTheme?: string | null;
@ApiProperty({ type: Number, required: false, description: "Time format", example: 24 })
@IsOptional()
@IsNumber()
@Validate(TimeFormatValidator)
@Expose()
timeFormat?: number;
@ApiProperty({ type: Number, required: false, description: "Default schedule ID", example: 1, minimum: 0 })
@IsOptional()
@IsNumber()
@Min(0)
@Expose()
defaultScheduleId?: number;
@ApiProperty({ type: String, required: false, description: "Locale", example: "en", default: "en" })
@IsOptional()
@IsString()
@Validate(LocaleValidator)
@Expose()
locale?: string | null = "en";
@ApiProperty({
type: String,
required: false,
description: "Avatar URL",
example: "https://example.com/avatar.jpg",
})
@IsOptional()
@IsString()
@Validate(AvatarValidator)
@Expose()
avatarUrl?: string;
}