From 7ef202c8b2957c891601b9796088cfc400d0cc24 Mon Sep 17 00:00:00 2001 From: Sam Holton Date: Mon, 4 Mar 2024 00:40:03 -0500 Subject: [PATCH] =?UTF-8?q?feat(server,=20web):=20add=20checkbox=20to=20cr?= =?UTF-8?q?eate=20user=20screen=20for=20shouldChang=E2=80=A6=20(#7598)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat(server, web): add checkbox to create user screen for shouldChangePassword --- mobile/openapi/doc/CreateUserDto.md | 1 + mobile/openapi/lib/model/create_user_dto.dart | 19 ++++++++++++++++++- mobile/openapi/test/create_user_dto_test.dart | 5 +++++ open-api/immich-openapi-specs.json | 3 +++ open-api/typescript-sdk/src/fetch-client.ts | 1 + server/src/domain/user/dto/create-user.dto.ts | 4 ++++ .../components/forms/create-user-form.svelte | 13 ++++++++++--- 7 files changed, 42 insertions(+), 4 deletions(-) diff --git a/mobile/openapi/doc/CreateUserDto.md b/mobile/openapi/doc/CreateUserDto.md index 0dcc8eca1f..743adb3a16 100644 --- a/mobile/openapi/doc/CreateUserDto.md +++ b/mobile/openapi/doc/CreateUserDto.md @@ -13,6 +13,7 @@ Name | Type | Description | Notes **name** | **String** | | **password** | **String** | | **quotaSizeInBytes** | **int** | | [optional] +**shouldChangePassword** | **bool** | | [optional] **storageLabel** | **String** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/mobile/openapi/lib/model/create_user_dto.dart b/mobile/openapi/lib/model/create_user_dto.dart index f272842cbe..2dada4f672 100644 --- a/mobile/openapi/lib/model/create_user_dto.dart +++ b/mobile/openapi/lib/model/create_user_dto.dart @@ -18,6 +18,7 @@ class CreateUserDto { required this.name, required this.password, this.quotaSizeInBytes, + this.shouldChangePassword, this.storageLabel, }); @@ -37,6 +38,14 @@ class CreateUserDto { int? quotaSizeInBytes; + /// + /// Please note: This property should have been non-nullable! Since the specification file + /// does not include a default value (using the "default:" property), however, the generated + /// source code must fall back to having a nullable type. + /// Consider adding a "default:" property in the specification file to hide this note. + /// + bool? shouldChangePassword; + String? storageLabel; @override @@ -46,6 +55,7 @@ class CreateUserDto { other.name == name && other.password == password && other.quotaSizeInBytes == quotaSizeInBytes && + other.shouldChangePassword == shouldChangePassword && other.storageLabel == storageLabel; @override @@ -56,10 +66,11 @@ class CreateUserDto { (name.hashCode) + (password.hashCode) + (quotaSizeInBytes == null ? 0 : quotaSizeInBytes!.hashCode) + + (shouldChangePassword == null ? 0 : shouldChangePassword!.hashCode) + (storageLabel == null ? 0 : storageLabel!.hashCode); @override - String toString() => 'CreateUserDto[email=$email, memoriesEnabled=$memoriesEnabled, name=$name, password=$password, quotaSizeInBytes=$quotaSizeInBytes, storageLabel=$storageLabel]'; + String toString() => 'CreateUserDto[email=$email, memoriesEnabled=$memoriesEnabled, name=$name, password=$password, quotaSizeInBytes=$quotaSizeInBytes, shouldChangePassword=$shouldChangePassword, storageLabel=$storageLabel]'; Map toJson() { final json = {}; @@ -76,6 +87,11 @@ class CreateUserDto { } else { // json[r'quotaSizeInBytes'] = null; } + if (this.shouldChangePassword != null) { + json[r'shouldChangePassword'] = this.shouldChangePassword; + } else { + // json[r'shouldChangePassword'] = null; + } if (this.storageLabel != null) { json[r'storageLabel'] = this.storageLabel; } else { @@ -97,6 +113,7 @@ class CreateUserDto { name: mapValueOfType(json, r'name')!, password: mapValueOfType(json, r'password')!, quotaSizeInBytes: mapValueOfType(json, r'quotaSizeInBytes'), + shouldChangePassword: mapValueOfType(json, r'shouldChangePassword'), storageLabel: mapValueOfType(json, r'storageLabel'), ); } diff --git a/mobile/openapi/test/create_user_dto_test.dart b/mobile/openapi/test/create_user_dto_test.dart index 9658c02c8a..da1d5fac7e 100644 --- a/mobile/openapi/test/create_user_dto_test.dart +++ b/mobile/openapi/test/create_user_dto_test.dart @@ -41,6 +41,11 @@ void main() { // TODO }); + // bool shouldChangePassword + test('to test the property `shouldChangePassword`', () async { + // TODO + }); + // String storageLabel test('to test the property `storageLabel`', () async { // TODO diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 8523d733a9..132df95b91 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -7672,6 +7672,9 @@ "nullable": true, "type": "integer" }, + "shouldChangePassword": { + "type": "boolean" + }, "storageLabel": { "nullable": true, "type": "string" diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index 27de8a375e..77fd06fe74 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -958,6 +958,7 @@ export type CreateUserDto = { name: string; password: string; quotaSizeInBytes?: number | null; + shouldChangePassword?: boolean; storageLabel?: string | null; }; export type UpdateUserDto = { diff --git a/server/src/domain/user/dto/create-user.dto.ts b/server/src/domain/user/dto/create-user.dto.ts index e6dbb81675..737b68c036 100644 --- a/server/src/domain/user/dto/create-user.dto.ts +++ b/server/src/domain/user/dto/create-user.dto.ts @@ -30,6 +30,10 @@ export class CreateUserDto { @IsPositive() @ApiProperty({ type: 'integer', format: 'int64' }) quotaSizeInBytes?: number | null; + + @Optional() + @IsBoolean() + shouldChangePassword?: boolean; } export class CreateAdminDto { diff --git a/web/src/lib/components/forms/create-user-form.svelte b/web/src/lib/components/forms/create-user-form.svelte index c83b5f6724..d3b52dbd86 100644 --- a/web/src/lib/components/forms/create-user-form.svelte +++ b/web/src/lib/components/forms/create-user-form.svelte @@ -7,12 +7,14 @@ import Button from '../elements/buttons/button.svelte'; import ImmichLogo from '../shared-components/immich-logo.svelte'; import PasswordField from '../shared-components/password-field.svelte'; + import Slider from '../elements/slider.svelte'; let error: string; let success: string; let password = ''; let confirmPassword = ''; + let shouldChangePassword = true; let canCreateUser = false; let quotaSize: number | undefined; @@ -54,6 +56,7 @@ createUserDto: { email: String(email), password: String(password), + shouldChangePassword: Boolean(shouldChangePassword), name: String(name), quotaSizeInBytes: quotaSize ? convertToBytes(Number(quotaSize), 'GiB') : null, }, @@ -79,9 +82,6 @@

Create new user

-

- Please provide your user with the password, they will have to change it on their first sign in. -

@@ -100,6 +100,13 @@ +
+ + +
+