@hedhog/admin 0.51.28 → 0.51.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/auth/auth.controller.d.ts +10 -2
  2. package/dist/auth/auth.controller.d.ts.map +1 -1
  3. package/dist/auth/auth.service.d.ts +13 -5
  4. package/dist/auth/auth.service.d.ts.map +1 -1
  5. package/dist/auth/auth.service.js +9 -12
  6. package/dist/auth/auth.service.js.map +1 -1
  7. package/dist/auth/dto/login-with-code.dto.d.ts +1 -1
  8. package/dist/auth/dto/login-with-code.dto.js +4 -4
  9. package/dist/auth/dto/login-with-code.dto.js.map +1 -1
  10. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +11 -11
  11. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +11 -11
  12. package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +3 -3
  13. package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +3 -3
  14. package/dist/menu/menu.controller.d.ts +3 -3
  15. package/dist/menu/menu.service.d.ts +3 -3
  16. package/frontend/dashboard/components/create-panel.tsx.ejs +63 -63
  17. package/frontend/dashboard/components/dashboard.screen.tsx.ejs +116 -116
  18. package/frontend/dashboard/components/update-panel.tsx.ejs +80 -80
  19. package/frontend/dashboard/locales/en/dashboard.dashboard.json +11 -11
  20. package/frontend/dashboard/locales/pt/dashboard.dashboard.json +11 -11
  21. package/frontend/dashboard/react-query/handlers.ts.ejs +28 -28
  22. package/frontend/dashboard/react-query/requests.ts.ejs +56 -56
  23. package/frontend/dashboard-component/components/create-panel.tsx.ejs +130 -130
  24. package/frontend/dashboard-component/components/update-panel.tsx.ejs +164 -164
  25. package/frontend/dashboard-component/locales/en/dashboard.dashboard-component.json +11 -11
  26. package/frontend/dashboard-component/locales/pt/dashboard.dashboard-component.json +11 -11
  27. package/frontend/dashboard-component/react-query/handlers.ts.ejs +28 -28
  28. package/frontend/dashboard-component/react-query/requests.ts.ejs +61 -61
  29. package/frontend/dashboard-item/components/create-panel.tsx.ejs +108 -108
  30. package/frontend/dashboard-item/components/update-panel.tsx.ejs +141 -141
  31. package/frontend/dashboard-item/locales/en/dashboard.dashboard-item.json +11 -11
  32. package/frontend/dashboard-item/locales/pt/dashboard.dashboard-item.json +11 -11
  33. package/frontend/dashboard-item/react-query/handlers.ts.ejs +28 -28
  34. package/frontend/dashboard-item/react-query/requests.ts.ejs +58 -58
  35. package/frontend/dashboard-user/components/create-panel.tsx.ejs +108 -108
  36. package/frontend/dashboard-user/components/update-panel.tsx.ejs +137 -137
  37. package/frontend/dashboard-user/locales/en/dashboard.dashboard-user.json +11 -11
  38. package/frontend/dashboard-user/locales/pt/dashboard.dashboard-user.json +11 -11
  39. package/frontend/dashboard-user/react-query/handlers.ts.ejs +28 -28
  40. package/frontend/dashboard-user/react-query/requests.ts.ejs +58 -58
  41. package/package.json +1 -1
  42. package/src/auth/auth.service.ts +11 -16
  43. package/src/auth/dto/login-with-code.dto.ts +5 -5
  44. package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -55
  45. package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -36
  46. package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -4
  47. package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -4
  48. package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -4
  49. package/src/dashboard/index.ts +1 -1
@@ -1,28 +1,28 @@
1
- import { useDefaultMutation } from "@/hooks/use-default-mutation";
2
- import { useQuery } from "@tanstack/react-query";
3
- import { requests } from "./requests";
4
-
5
- const scope = "dashboard-user";
6
-
7
- export function useDashboardUserCreate() {
8
- const { dashboardUserCreate } = requests();
9
- return useDefaultMutation(scope, "create", dashboardUserCreate);
10
- }
11
-
12
- export function useDashboardUserDelete() {
13
- const { dashboardUserDelete } = requests();
14
- return useDefaultMutation(scope, "delete", dashboardUserDelete);
15
- }
16
-
17
- export function useDashboardUserUpdate() {
18
- const { dashboardUserUpdate } = requests();
19
- return useDefaultMutation(scope, "update", dashboardUserUpdate);
20
- }
21
-
22
- export function useDashboardUserGet(id: number) {
23
- const { dashboardUserGet } = requests();
24
- return useQuery({
25
- queryKey: [scope, "get"],
26
- queryFn: () => dashboardUserGet(id),
27
- });
28
- }
1
+ import { useDefaultMutation } from "@/hooks/use-default-mutation";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { requests } from "./requests";
4
+
5
+ const scope = "dashboard-user";
6
+
7
+ export function useDashboardUserCreate() {
8
+ const { dashboardUserCreate } = requests();
9
+ return useDefaultMutation(scope, "create", dashboardUserCreate);
10
+ }
11
+
12
+ export function useDashboardUserDelete() {
13
+ const { dashboardUserDelete } = requests();
14
+ return useDefaultMutation(scope, "delete", dashboardUserDelete);
15
+ }
16
+
17
+ export function useDashboardUserUpdate() {
18
+ const { dashboardUserUpdate } = requests();
19
+ return useDefaultMutation(scope, "update", dashboardUserUpdate);
20
+ }
21
+
22
+ export function useDashboardUserGet(id: number) {
23
+ const { dashboardUserGet } = requests();
24
+ return useQuery({
25
+ queryKey: [scope, "get"],
26
+ queryFn: () => dashboardUserGet(id),
27
+ });
28
+ }
@@ -1,58 +1,58 @@
1
- import { useApp } from "@/hooks/use-app";
2
- import { Delete, PaginationParams, PaginationResult } from "@/types";
3
- import { DashboardUser } from "@/types/models";
4
- import { HttpMethod } from "@/types/http-method";
5
-
6
- export function requests() {
7
- const { request } = useApp();
8
-
9
- const dashboardUserList = async (params: PaginationParams) => {
10
- return request<PaginationResult<DashboardUser>>({
11
- url: "/dashboard-user",
12
- params,
13
- }).then((res) => res.data);
14
- };
15
-
16
- const dashboardUserGet = async (id: number) => {
17
- return request<DashboardUser>({
18
- url: `/dashboard-user/${id}`,
19
- }).then((res) => res.data);
20
- };
21
-
22
- const dashboardUserCreate = async (params: { data: DashboardUser }) => {
23
- const { data } = params;
24
- return request<DashboardUser>({
25
- url: "/dashboard-user",
26
- method: HttpMethod.POST,
27
- data: data,
28
- }).then((res) => res.data);
29
- };
30
-
31
- const dashboardUserDelete = async (ids: number[]) => {
32
- return request<Delete>({
33
- url: "/dashboard-user",
34
- data: { ids },
35
- method: HttpMethod.DELETE,
36
- }).then((res) => res.data);
37
- };
38
-
39
- const dashboardUserUpdate = async (params: {
40
- id: number;
41
- data: DashboardUser;
42
- }) => {
43
- const { id, data } = params;
44
- return request<DashboardUser>({
45
- url: `/dashboard-user/${id}`,
46
- method: HttpMethod.PATCH,
47
- data: data,
48
- }).then((res) => res.data);
49
- };
50
-
51
- return {
52
- dashboardUserCreate,
53
- dashboardUserUpdate,
54
- dashboardUserDelete,
55
- dashboardUserList,
56
- dashboardUserGet,
57
- };
58
- }
1
+ import { useApp } from "@/hooks/use-app";
2
+ import { Delete, PaginationParams, PaginationResult } from "@/types";
3
+ import { DashboardUser } from "@/types/models";
4
+ import { HttpMethod } from "@/types/http-method";
5
+
6
+ export function requests() {
7
+ const { request } = useApp();
8
+
9
+ const dashboardUserList = async (params: PaginationParams) => {
10
+ return request<PaginationResult<DashboardUser>>({
11
+ url: "/dashboard-user",
12
+ params,
13
+ }).then((res) => res.data);
14
+ };
15
+
16
+ const dashboardUserGet = async (id: number) => {
17
+ return request<DashboardUser>({
18
+ url: `/dashboard-user/${id}`,
19
+ }).then((res) => res.data);
20
+ };
21
+
22
+ const dashboardUserCreate = async (params: { data: DashboardUser }) => {
23
+ const { data } = params;
24
+ return request<DashboardUser>({
25
+ url: "/dashboard-user",
26
+ method: HttpMethod.POST,
27
+ data: data,
28
+ }).then((res) => res.data);
29
+ };
30
+
31
+ const dashboardUserDelete = async (ids: number[]) => {
32
+ return request<Delete>({
33
+ url: "/dashboard-user",
34
+ data: { ids },
35
+ method: HttpMethod.DELETE,
36
+ }).then((res) => res.data);
37
+ };
38
+
39
+ const dashboardUserUpdate = async (params: {
40
+ id: number;
41
+ data: DashboardUser;
42
+ }) => {
43
+ const { id, data } = params;
44
+ return request<DashboardUser>({
45
+ url: `/dashboard-user/${id}`,
46
+ method: HttpMethod.PATCH,
47
+ data: data,
48
+ }).then((res) => res.data);
49
+ };
50
+
51
+ return {
52
+ dashboardUserCreate,
53
+ dashboardUserUpdate,
54
+ dashboardUserDelete,
55
+ dashboardUserList,
56
+ dashboardUserGet,
57
+ };
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedhog/admin",
3
- "version": "0.51.28",
3
+ "version": "0.51.29",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -82,6 +82,11 @@ export class AuthService implements OnModuleInit {
82
82
  return user;
83
83
  }
84
84
 
85
+ async getPasswordHashed(password: string): Promise<string> {
86
+ const salt = await genSalt();
87
+ return await hash(password, salt);
88
+ }
89
+
85
90
  async register({ email, name, password, code, multifactor_id }: RegisterDTO) {
86
91
  const user = await this.prisma.user.findFirst({
87
92
  where: {
@@ -93,14 +98,11 @@ export class AuthService implements OnModuleInit {
93
98
  throw new ConflictException('Already exists a user with this email');
94
99
  }
95
100
 
96
- const salt = await genSalt();
97
- password = await hash(password, salt);
98
-
99
101
  const newUser = await this.prisma.user.create({
100
102
  data: {
101
103
  email,
102
104
  name,
103
- password,
105
+ password: await this.getPasswordHashed(password),
104
106
  multifactor_id,
105
107
  code,
106
108
  },
@@ -125,15 +127,13 @@ export class AuthService implements OnModuleInit {
125
127
  ) {
126
128
  try {
127
129
  const user = await this.createUserCheck(code);
128
- const salt = await genSalt();
129
- password = await hash(password, salt);
130
130
 
131
131
  await this.prisma.user.update({
132
132
  where: {
133
133
  id: user.id,
134
134
  },
135
135
  data: {
136
- password,
136
+ password: await this.getPasswordHashed(password),
137
137
  code: null,
138
138
  },
139
139
  });
@@ -290,6 +290,7 @@ export class AuthService implements OnModuleInit {
290
290
 
291
291
  return {
292
292
  token: this.jwt.sign(payload),
293
+ mfa: false,
293
294
  };
294
295
  }
295
296
 
@@ -356,15 +357,12 @@ export class AuthService implements OnModuleInit {
356
357
  throw new NotFoundException('Não foi possível alterar a senha.');
357
358
  }
358
359
 
359
- const salt = await genSalt();
360
- const password = await hash(newPassword, salt);
361
-
362
360
  const newUser = await this.prisma.user.update({
363
361
  where: {
364
362
  id: user.id,
365
363
  },
366
364
  data: {
367
- password,
365
+ password: await this.getPasswordHashed(newPassword),
368
366
  },
369
367
  });
370
368
 
@@ -458,15 +456,12 @@ export class AuthService implements OnModuleInit {
458
456
  });
459
457
 
460
458
  if (user) {
461
- const salt = await genSalt();
462
- const password = await hash(confirmNewPassword, salt);
463
-
464
459
  await this.prisma.user.update({
465
460
  where: {
466
461
  id: user.id,
467
462
  },
468
463
  data: {
469
- password,
464
+ password: await this.getPasswordHashed(confirmNewPassword),
470
465
  code: null,
471
466
  },
472
467
  });
@@ -488,7 +483,7 @@ export class AuthService implements OnModuleInit {
488
483
  }
489
484
  }
490
485
 
491
- async checkCodeMfa(userId: number, code: number) {
486
+ async checkCodeMfa(userId: number, code: string) {
492
487
  const window = this.settings['mfa-window'] ?? 0;
493
488
  const step = this.settings['mfa-setp'] ?? 30;
494
489
 
@@ -1,10 +1,10 @@
1
- import { IsInt, IsJWT, Max, Min } from 'class-validator';
1
+ import { IsJWT, IsString, Matches } from 'class-validator';
2
2
 
3
3
  export class LoginWithCodeDTO {
4
- @Min(0, { message: 'O código deve ser pelo menos 0.' })
5
- @Max(999999, { message: 'O código deve ser no máximo 999999.' })
6
- @IsInt({ message: 'O código deve ser um número inteiro.' })
7
- code: number;
4
+ @IsString({ message: 'O código deve ser uma string' })
5
+ @IsString({ message: 'O código deve ser uma string' })
6
+ @Matches(/^\d{6}$/, { message: 'O código deve conter 6 dígitos numéricos' })
7
+ code: string;
8
8
 
9
9
  @IsJWT({ message: 'Token inválido' })
10
10
  token: string;
@@ -1,55 +1,55 @@
1
- import { Pagination } from '@hedhog/pagination';
2
- import { Locale } from '@hedhog/locale';
3
- import {
4
- Body,
5
- Controller,
6
- Delete,
7
- Get,
8
- Inject,
9
- Param,
10
- ParseIntPipe,
11
- Patch,
12
- Post,
13
- forwardRef
14
- } from '@nestjs/common';
15
- import { CreateDTO } from './dto/create.dto';
16
- import { UpdateDTO } from './dto/update.dto';
17
- import { DashboardComponentService } from './dashboard-component.service';
18
- import { Role, DeleteDTO } from '@hedhog/core';
19
-
20
- @Role()
21
- @Controller('dashboard-component')
22
- export class DashboardComponentController {
23
- constructor(
24
- @Inject(forwardRef(() => DashboardComponentService))
25
- private readonly dashboardComponentService: DashboardComponentService
26
- ) {}
27
-
28
- @Get()
29
- async list(@Locale() locale, @Pagination() paginationParams) {
30
- return this.dashboardComponentService.list(locale, paginationParams);
31
- }
32
-
33
- @Get(':id')
34
- async get(@Param('id', ParseIntPipe) id: number) {
35
- return this.dashboardComponentService.get(id);
36
- }
37
-
38
- @Post()
39
- async create(@Body() data: CreateDTO) {
40
- return this.dashboardComponentService.create(data);
41
- }
42
-
43
- @Patch(':id')
44
- async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
45
- return this.dashboardComponentService.update({
46
- id,
47
- data
48
- });
49
- }
50
-
51
- @Delete()
52
- async delete(@Body() data: DeleteDTO) {
53
- return this.dashboardComponentService.delete(data);
54
- }
55
- }
1
+ import { Pagination } from '@hedhog/pagination';
2
+ import { Locale } from '@hedhog/locale';
3
+ import {
4
+ Body,
5
+ Controller,
6
+ Delete,
7
+ Get,
8
+ Inject,
9
+ Param,
10
+ ParseIntPipe,
11
+ Patch,
12
+ Post,
13
+ forwardRef
14
+ } from '@nestjs/common';
15
+ import { CreateDTO } from './dto/create.dto';
16
+ import { UpdateDTO } from './dto/update.dto';
17
+ import { DashboardComponentService } from './dashboard-component.service';
18
+ import { Role, DeleteDTO } from '@hedhog/core';
19
+
20
+ @Role()
21
+ @Controller('dashboard-component')
22
+ export class DashboardComponentController {
23
+ constructor(
24
+ @Inject(forwardRef(() => DashboardComponentService))
25
+ private readonly dashboardComponentService: DashboardComponentService
26
+ ) {}
27
+
28
+ @Get()
29
+ async list(@Locale() locale, @Pagination() paginationParams) {
30
+ return this.dashboardComponentService.list(locale, paginationParams);
31
+ }
32
+
33
+ @Get(':id')
34
+ async get(@Param('id', ParseIntPipe) id: number) {
35
+ return this.dashboardComponentService.get(id);
36
+ }
37
+
38
+ @Post()
39
+ async create(@Body() data: CreateDTO) {
40
+ return this.dashboardComponentService.create(data);
41
+ }
42
+
43
+ @Patch(':id')
44
+ async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
45
+ return this.dashboardComponentService.update({
46
+ id,
47
+ data
48
+ });
49
+ }
50
+
51
+ @Delete()
52
+ async delete(@Body() data: DeleteDTO) {
53
+ return this.dashboardComponentService.delete(data);
54
+ }
55
+ }
@@ -1,36 +1,36 @@
1
- import { IsString, IsNumber, IsBoolean, IsOptional } from 'class-validator';
2
- import { WithLocaleDTO } from '@hedhog/locale';
3
-
4
- export class CreateDTO extends WithLocaleDTO {
5
- @IsString()
6
- slug: string;
7
-
8
- @IsString()
9
- path: string;
10
-
11
- @IsOptional()
12
- @IsNumber()
13
- min_width?: number;
14
-
15
- @IsOptional()
16
- @IsNumber()
17
- max_width?: number;
18
-
19
- @IsOptional()
20
- @IsNumber()
21
- min_height?: number;
22
-
23
- @IsOptional()
24
- @IsNumber()
25
- max_height?: number;
26
-
27
- @IsNumber()
28
- width: number;
29
-
30
- @IsNumber()
31
- height: number;
32
-
33
- @IsOptional()
34
- @IsBoolean()
35
- is_resizable?: boolean;
36
- }
1
+ import { IsString, IsNumber, IsBoolean, IsOptional } from 'class-validator';
2
+ import { WithLocaleDTO } from '@hedhog/locale';
3
+
4
+ export class CreateDTO extends WithLocaleDTO {
5
+ @IsString()
6
+ slug: string;
7
+
8
+ @IsString()
9
+ path: string;
10
+
11
+ @IsOptional()
12
+ @IsNumber()
13
+ min_width?: number;
14
+
15
+ @IsOptional()
16
+ @IsNumber()
17
+ max_width?: number;
18
+
19
+ @IsOptional()
20
+ @IsNumber()
21
+ min_height?: number;
22
+
23
+ @IsOptional()
24
+ @IsNumber()
25
+ max_height?: number;
26
+
27
+ @IsNumber()
28
+ width: number;
29
+
30
+ @IsNumber()
31
+ height: number;
32
+
33
+ @IsOptional()
34
+ @IsBoolean()
35
+ is_resizable?: boolean;
36
+ }
@@ -1,4 +1,4 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateDTO } from './create.dto';
3
+
4
+ export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1,4 +1,4 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateDTO } from './create.dto';
3
+
4
+ export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1,4 +1,4 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateDTO } from './create.dto';
3
+
4
+ export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1 +1 @@
1
- export * from './dashboard.module';
1
+ export * from './dashboard.module';