diff options
| author | kamtschatka <simon.schatka@gmx.at> | 2024-10-19 23:48:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-19 22:48:14 +0100 |
| commit | 9a56e58bd54b2bfe11104e80c602493d720ff6be (patch) | |
| tree | bd5ac7c8dd386881f077519e40d911d8e07dbace /packages/shared | |
| parent | 0debc6b415baa466245901fb52c009d09ef3ba15 (diff) | |
| download | karakeep-9a56e58bd54b2bfe11104e80c602493d720ff6be.tar.zst | |
feature: Allow reseting user password, change their roles and create new users. Fixes #495 (#567)
* How do I set the variable "user" or "system" for AI inference #262
changed from system to user
* Make Myself an Admin #560
added user management functionality to the admin page
* A bunch of UI fixes and simplifications
---------
Co-authored-by: Mohamed Bassem <me@mbassem.com>
Diffstat (limited to 'packages/shared')
| -rw-r--r-- | packages/shared/types/admin.ts | 25 | ||||
| -rw-r--r-- | packages/shared/types/users.ts | 2 |
2 files changed, 26 insertions, 1 deletions
diff --git a/packages/shared/types/admin.ts b/packages/shared/types/admin.ts new file mode 100644 index 00000000..8b16dfd0 --- /dev/null +++ b/packages/shared/types/admin.ts @@ -0,0 +1,25 @@ +import { z } from "zod"; + +import { PASSWORD_MAX_LENGTH, zSignUpSchema } from "./users"; + +export const zRoleSchema = z.object({ + role: z.enum(["user", "admin"]), +}); + +export const zAdminCreateUserSchema = zSignUpSchema.and(zRoleSchema); + +export const changeRoleSchema = z.object({ + userId: z.string(), + role: z.enum(["user", "admin"]), +}); + +export const resetPasswordSchema = z + .object({ + userId: z.string(), + newPassword: z.string().min(8).max(PASSWORD_MAX_LENGTH), + newPasswordConfirm: z.string(), + }) + .refine((data) => data.newPassword === data.newPasswordConfirm, { + message: "Passwords don't match", + path: ["newPasswordConfirm"], + }); diff --git a/packages/shared/types/users.ts b/packages/shared/types/users.ts index 3026337a..7d97a6d9 100644 --- a/packages/shared/types/users.ts +++ b/packages/shared/types/users.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -const PASSWORD_MAX_LENGTH = 100; +export const PASSWORD_MAX_LENGTH = 100; export const zSignUpSchema = z .object({ |
