@hedhog/admin 0.51.20 → 0.51.21
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.
- package/dist/admin.module.d.ts.map +1 -1
- package/dist/admin.module.js +3 -0
- package/dist/admin.module.js.map +1 -1
- package/dist/auth/auth.controller.d.ts +6 -6
- package/dist/auth/auth.controller.d.ts.map +1 -1
- package/dist/auth/auth.controller.js +35 -24
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/auth.module.d.ts.map +1 -1
- package/dist/auth/auth.module.js +2 -0
- package/dist/auth/auth.module.js.map +1 -1
- package/dist/auth/auth.service.d.ts +9 -9
- package/dist/auth/auth.service.d.ts.map +1 -1
- package/dist/auth/auth.service.js +38 -39
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +11 -11
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +11 -11
- package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +3 -3
- package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +3 -3
- package/dist/menu/menu.controller.d.ts +3 -3
- package/dist/menu/menu.service.d.ts +3 -3
- package/frontend/dashboard/components/create-panel.tsx.ejs +63 -63
- package/frontend/dashboard/components/dashboard.screen.tsx.ejs +116 -116
- package/frontend/dashboard/components/update-panel.tsx.ejs +80 -80
- package/frontend/dashboard/locales/en/dashboard.dashboard.json +11 -11
- package/frontend/dashboard/locales/pt/dashboard.dashboard.json +11 -11
- package/frontend/dashboard/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard/react-query/requests.ts.ejs +56 -56
- package/frontend/dashboard-component/components/create-panel.tsx.ejs +130 -130
- package/frontend/dashboard-component/components/update-panel.tsx.ejs +164 -164
- package/frontend/dashboard-component/locales/en/dashboard.dashboard-component.json +11 -11
- package/frontend/dashboard-component/locales/pt/dashboard.dashboard-component.json +11 -11
- package/frontend/dashboard-component/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard-component/react-query/requests.ts.ejs +61 -61
- package/frontend/dashboard-item/components/create-panel.tsx.ejs +108 -108
- package/frontend/dashboard-item/components/update-panel.tsx.ejs +141 -141
- package/frontend/dashboard-item/locales/en/dashboard.dashboard-item.json +11 -11
- package/frontend/dashboard-item/locales/pt/dashboard.dashboard-item.json +11 -11
- package/frontend/dashboard-item/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard-item/react-query/requests.ts.ejs +58 -58
- package/frontend/dashboard-user/components/create-panel.tsx.ejs +108 -108
- package/frontend/dashboard-user/components/update-panel.tsx.ejs +137 -137
- package/frontend/dashboard-user/locales/en/dashboard.dashboard-user.json +11 -11
- package/frontend/dashboard-user/locales/pt/dashboard.dashboard-user.json +11 -11
- package/frontend/dashboard-user/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard-user/react-query/requests.ts.ejs +58 -58
- package/package.json +3 -1
- package/src/admin.module.ts +3 -0
- package/src/auth/auth.controller.ts +23 -10
- package/src/auth/auth.module.ts +2 -0
- package/src/auth/auth.service.ts +64 -60
- package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -55
- package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -36
- package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -4
- package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -4
- package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -4
- 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.
|
3
|
+
"version": "0.51.21",
|
4
4
|
"private": false,
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"scripts": {
|
@@ -27,6 +27,7 @@
|
|
27
27
|
"devDependencies": {
|
28
28
|
"@hedhog/locale": "^0.48.4",
|
29
29
|
"@hedhog/mail": "^0.48.1",
|
30
|
+
"@hedhog/mail-manager": "^0.48.20",
|
30
31
|
"@hedhog/pagination": "^0.46.1",
|
31
32
|
"@hedhog/prisma": "^0.46.1",
|
32
33
|
"@hedhog/utils": "^0.0.28",
|
@@ -39,6 +40,7 @@
|
|
39
40
|
"peerDependencies": {
|
40
41
|
"@hedhog/locale": "latest",
|
41
42
|
"@hedhog/mail": "latest",
|
43
|
+
"@hedhog/mail-manager": "latest",
|
42
44
|
"@hedhog/pagination": "latest",
|
43
45
|
"@hedhog/prisma": "latest",
|
44
46
|
"@hedhog/utils": "latest",
|
package/src/admin.module.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { LocaleModule } from '@hedhog/locale';
|
2
2
|
import { MailModule } from '@hedhog/mail';
|
3
|
+
import { MailManagerModule } from '@hedhog/mail-manager';
|
3
4
|
import { PaginationModule } from '@hedhog/pagination';
|
4
5
|
import { PrismaModule } from '@hedhog/prisma';
|
5
6
|
import { HttpModule } from '@nestjs/axios';
|
@@ -22,6 +23,7 @@ import { UserModule } from './user/user.module';
|
|
22
23
|
forwardRef(() => AuthModule),
|
23
24
|
forwardRef(() => DashboardModule),
|
24
25
|
forwardRef(() => MailModule),
|
26
|
+
forwardRef(() => MailManagerModule),
|
25
27
|
forwardRef(() => MenuModule),
|
26
28
|
forwardRef(() => PaginationModule),
|
27
29
|
forwardRef(() => RoleModule),
|
@@ -37,6 +39,7 @@ import { UserModule } from './user/user.module';
|
|
37
39
|
UserModule,
|
38
40
|
AuthModule,
|
39
41
|
MailModule,
|
42
|
+
MailManagerModule,
|
40
43
|
RouteModule,
|
41
44
|
RoleModule,
|
42
45
|
MenuModule,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Public, Role, User } from '@hedhog/core';
|
2
|
+
import { Locale } from '@hedhog/locale';
|
2
3
|
import {
|
3
4
|
Body,
|
4
5
|
Controller,
|
@@ -36,8 +37,8 @@ export class AuthController {
|
|
36
37
|
|
37
38
|
@Public()
|
38
39
|
@Post('create-user')
|
39
|
-
async createUser(@Body() data: CreateUserDTO) {
|
40
|
-
return this.service.createUser(data);
|
40
|
+
async createUser(@Locale() Locale, @Body() data: CreateUserDTO) {
|
41
|
+
return this.service.createUser(Locale, data);
|
41
42
|
}
|
42
43
|
|
43
44
|
@Role()
|
@@ -48,8 +49,8 @@ export class AuthController {
|
|
48
49
|
|
49
50
|
@Public()
|
50
51
|
@Post('login')
|
51
|
-
async login(@Body() { email, password }: LoginDTO) {
|
52
|
-
return this.service.login({ email, password });
|
52
|
+
async login(@Locale() locale: string, @Body() { email, password }: LoginDTO) {
|
53
|
+
return this.service.login(locale, { email, password });
|
53
54
|
}
|
54
55
|
|
55
56
|
@Public()
|
@@ -81,6 +82,7 @@ export class AuthController {
|
|
81
82
|
@Public()
|
82
83
|
@Post('forget')
|
83
84
|
async forget(
|
85
|
+
@Locale() locale: string,
|
84
86
|
@Body()
|
85
87
|
{
|
86
88
|
email,
|
@@ -89,15 +91,18 @@ export class AuthController {
|
|
89
91
|
body: string;
|
90
92
|
},
|
91
93
|
) {
|
92
|
-
return this.service.forget({
|
94
|
+
return this.service.forget(locale, {
|
93
95
|
email,
|
94
96
|
});
|
95
97
|
}
|
96
98
|
|
97
99
|
@Public()
|
98
100
|
@Post('reset')
|
99
|
-
async reset(
|
100
|
-
|
101
|
+
async reset(
|
102
|
+
@Locale() locale: string,
|
103
|
+
@Body() { newPassword, confirmNewPassword, code }: ResetDTO,
|
104
|
+
) {
|
105
|
+
return this.service.resetPassword(locale, {
|
101
106
|
newPassword,
|
102
107
|
confirmNewPassword,
|
103
108
|
code,
|
@@ -107,10 +112,11 @@ export class AuthController {
|
|
107
112
|
@Public()
|
108
113
|
@Post('change-password')
|
109
114
|
async changePassword(
|
115
|
+
@Locale() locale: string,
|
110
116
|
@Body()
|
111
117
|
{ email, currentPassword, newPassword, confirmNewPassword }: ChangeDTO,
|
112
118
|
) {
|
113
|
-
return this.service.changePassword({
|
119
|
+
return this.service.changePassword(locale, {
|
114
120
|
email,
|
115
121
|
currentPassword,
|
116
122
|
newPassword,
|
@@ -119,8 +125,15 @@ export class AuthController {
|
|
119
125
|
}
|
120
126
|
|
121
127
|
@Post('change-email')
|
122
|
-
async changeEmail(
|
123
|
-
|
128
|
+
async changeEmail(
|
129
|
+
@Locale() locale: string,
|
130
|
+
@Body() { currentEmail, password, newEmail }: EmailDTO,
|
131
|
+
) {
|
132
|
+
return this.service.changeEmail(locale, {
|
133
|
+
currentEmail,
|
134
|
+
password,
|
135
|
+
newEmail,
|
136
|
+
});
|
124
137
|
}
|
125
138
|
|
126
139
|
@Delete('mfa-remove')
|
package/src/auth/auth.module.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { MailModule } from '@hedhog/mail';
|
2
|
+
import { MailManagerModule } from '@hedhog/mail-manager';
|
2
3
|
import { PrismaModule } from '@hedhog/prisma';
|
3
4
|
import { HttpModule } from '@nestjs/axios';
|
4
5
|
import { forwardRef, Module } from '@nestjs/common';
|
@@ -28,6 +29,7 @@ import { AuthGuard } from './guards/auth.guard';
|
|
28
29
|
),
|
29
30
|
forwardRef(() => PrismaModule),
|
30
31
|
forwardRef(() => MailModule),
|
32
|
+
forwardRef(() => MailManagerModule),
|
31
33
|
forwardRef(() => SettingModule),
|
32
34
|
ConfigModule,
|
33
35
|
HttpModule,
|
package/src/auth/auth.service.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { MailService } from '@hedhog/mail';
|
1
|
+
import { MailService as MailManagerService } from '@hedhog/mail-manager';
|
2
2
|
import { PrismaService } from '@hedhog/prisma';
|
3
3
|
import { HttpService } from '@nestjs/axios';
|
4
4
|
import {
|
@@ -16,13 +16,6 @@ import { compare, genSalt, hash } from 'bcrypt';
|
|
16
16
|
import * as qrcode from 'qrcode';
|
17
17
|
import { lastValueFrom } from 'rxjs';
|
18
18
|
import * as speakeasy from 'speakeasy';
|
19
|
-
import {
|
20
|
-
getChangeEmailEmail,
|
21
|
-
getChangePasswordEmail,
|
22
|
-
getCreateUserEmail,
|
23
|
-
getForgetPasswordEmail,
|
24
|
-
getResetPasswordEmail,
|
25
|
-
} from '../emails';
|
26
19
|
import { SettingService } from '../setting/setting.service';
|
27
20
|
import { ChangeDTO } from './dto/change.dto';
|
28
21
|
import { CreateUserDTO } from './dto/create-user.dto';
|
@@ -45,8 +38,8 @@ export class AuthService implements OnModuleInit {
|
|
45
38
|
private readonly prisma: PrismaService,
|
46
39
|
@Inject(forwardRef(() => JwtService))
|
47
40
|
private readonly jwt: JwtService,
|
48
|
-
@Inject(forwardRef(() =>
|
49
|
-
private readonly mail:
|
41
|
+
@Inject(forwardRef(() => MailManagerService))
|
42
|
+
private readonly mail: MailManagerService,
|
50
43
|
@Inject(forwardRef(() => SettingService))
|
51
44
|
private readonly setting: SettingService,
|
52
45
|
) {}
|
@@ -116,17 +109,20 @@ export class AuthService implements OnModuleInit {
|
|
116
109
|
return this.getToken(newUser);
|
117
110
|
}
|
118
111
|
|
119
|
-
async createUser(
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
112
|
+
async createUser(
|
113
|
+
locale: string,
|
114
|
+
{
|
115
|
+
code,
|
116
|
+
password,
|
117
|
+
street,
|
118
|
+
number,
|
119
|
+
complement,
|
120
|
+
district,
|
121
|
+
city,
|
122
|
+
state,
|
123
|
+
postal_code,
|
124
|
+
}: CreateUserDTO,
|
125
|
+
) {
|
130
126
|
try {
|
131
127
|
const user = await this.createUserCheck(code);
|
132
128
|
const salt = await genSalt();
|
@@ -191,12 +187,10 @@ export class AuthService implements OnModuleInit {
|
|
191
187
|
});
|
192
188
|
}
|
193
189
|
|
194
|
-
await this.mail.
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
name: user.name,
|
199
|
-
}),
|
190
|
+
await this.mail.sendTemplatedMail(locale, {
|
191
|
+
email: user.email,
|
192
|
+
slug: 'create-user',
|
193
|
+
variables: {},
|
200
194
|
});
|
201
195
|
|
202
196
|
return this.getToken(user);
|
@@ -228,7 +222,11 @@ export class AuthService implements OnModuleInit {
|
|
228
222
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
229
223
|
}
|
230
224
|
|
231
|
-
async loginWithEmailAndPassword(
|
225
|
+
async loginWithEmailAndPassword(
|
226
|
+
locale: string,
|
227
|
+
email: string,
|
228
|
+
password: string,
|
229
|
+
) {
|
232
230
|
const user = await this.prisma.user.findFirst({
|
233
231
|
where: {
|
234
232
|
email,
|
@@ -260,10 +258,10 @@ export class AuthService implements OnModuleInit {
|
|
260
258
|
},
|
261
259
|
});
|
262
260
|
|
263
|
-
await this.mail.
|
264
|
-
|
265
|
-
|
266
|
-
|
261
|
+
await this.mail.sendTemplatedMail(locale, {
|
262
|
+
email: user.email,
|
263
|
+
slug: 'login',
|
264
|
+
variables: { code: String(code) },
|
267
265
|
});
|
268
266
|
|
269
267
|
return {
|
@@ -295,7 +293,7 @@ export class AuthService implements OnModuleInit {
|
|
295
293
|
};
|
296
294
|
}
|
297
295
|
|
298
|
-
async forget({ email }: ForgetDTO) {
|
296
|
+
async forget(locale: string, { email }: ForgetDTO) {
|
299
297
|
const appUrl =
|
300
298
|
process.env.APP_URL ?? this.configService.get<string>('APP_URL');
|
301
299
|
|
@@ -324,10 +322,13 @@ export class AuthService implements OnModuleInit {
|
|
324
322
|
},
|
325
323
|
});
|
326
324
|
|
327
|
-
await this.mail.
|
328
|
-
|
329
|
-
|
330
|
-
|
325
|
+
await this.mail.sendTemplatedMail(locale, {
|
326
|
+
email,
|
327
|
+
slug: 'forget',
|
328
|
+
variables: {
|
329
|
+
appUrl,
|
330
|
+
code,
|
331
|
+
},
|
331
332
|
});
|
332
333
|
}
|
333
334
|
|
@@ -337,12 +338,10 @@ export class AuthService implements OnModuleInit {
|
|
337
338
|
};
|
338
339
|
}
|
339
340
|
|
340
|
-
async changePassword(
|
341
|
-
|
342
|
-
currentPassword,
|
343
|
-
|
344
|
-
confirmNewPassword,
|
345
|
-
}: ChangeDTO) {
|
341
|
+
async changePassword(
|
342
|
+
locale: string,
|
343
|
+
{ email, currentPassword, newPassword, confirmNewPassword }: ChangeDTO,
|
344
|
+
) {
|
346
345
|
if (newPassword !== confirmNewPassword) {
|
347
346
|
throw new BadRequestException('Senhas não conferem');
|
348
347
|
}
|
@@ -367,16 +366,19 @@ export class AuthService implements OnModuleInit {
|
|
367
366
|
},
|
368
367
|
});
|
369
368
|
|
370
|
-
await this.mail.
|
371
|
-
|
372
|
-
|
373
|
-
|
369
|
+
await this.mail.sendTemplatedMail(locale, {
|
370
|
+
email,
|
371
|
+
slug: 'change-password',
|
372
|
+
variables: {},
|
374
373
|
});
|
375
374
|
|
376
375
|
return this.getToken(newUser);
|
377
376
|
}
|
378
377
|
|
379
|
-
async changeEmail(
|
378
|
+
async changeEmail(
|
379
|
+
locale: string,
|
380
|
+
{ currentEmail, password, newEmail }: EmailDTO,
|
381
|
+
) {
|
380
382
|
const user = await this.prisma.user.findFirst({
|
381
383
|
where: { email: currentEmail },
|
382
384
|
});
|
@@ -424,16 +426,19 @@ export class AuthService implements OnModuleInit {
|
|
424
426
|
data: { value: newEmail },
|
425
427
|
});
|
426
428
|
|
427
|
-
await this.mail.
|
428
|
-
|
429
|
-
|
430
|
-
|
429
|
+
await this.mail.sendTemplatedMail(locale, {
|
430
|
+
email: newEmail,
|
431
|
+
slug: 'change-email',
|
432
|
+
variables: {},
|
431
433
|
});
|
432
434
|
|
433
435
|
return this.getToken(newUser);
|
434
436
|
}
|
435
437
|
|
436
|
-
async resetPassword(
|
438
|
+
async resetPassword(
|
439
|
+
locale: string,
|
440
|
+
{ code, newPassword, confirmNewPassword }: ResetDTO,
|
441
|
+
) {
|
437
442
|
if (newPassword !== confirmNewPassword) {
|
438
443
|
throw new BadRequestException('Senhas não conferem');
|
439
444
|
}
|
@@ -464,10 +469,10 @@ export class AuthService implements OnModuleInit {
|
|
464
469
|
},
|
465
470
|
});
|
466
471
|
|
467
|
-
await this.mail.
|
468
|
-
|
469
|
-
|
470
|
-
|
472
|
+
await this.mail.sendTemplatedMail(locale, {
|
473
|
+
email: user.email,
|
474
|
+
slug: 'reset-password',
|
475
|
+
variables: {},
|
471
476
|
});
|
472
477
|
|
473
478
|
return this.getToken(user);
|
@@ -518,7 +523,6 @@ export class AuthService implements OnModuleInit {
|
|
518
523
|
|
519
524
|
switch (data.mfa) {
|
520
525
|
case MultifactorType.EMAIL:
|
521
|
-
//TO DO
|
522
526
|
case MultifactorType.APP:
|
523
527
|
const codes = await this.prisma.user_code_recovery.findMany({
|
524
528
|
where: {
|
@@ -607,8 +611,8 @@ export class AuthService implements OnModuleInit {
|
|
607
611
|
}
|
608
612
|
}
|
609
613
|
|
610
|
-
async login({ email, password }: LoginDTO) {
|
611
|
-
return this.loginWithEmailAndPassword(email, password);
|
614
|
+
async login(locale: string, { email, password }: LoginDTO) {
|
615
|
+
return this.loginWithEmailAndPassword(locale, email, password);
|
612
616
|
}
|
613
617
|
|
614
618
|
async verify(id: number) {
|
@@ -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
|
+
}
|