@hedhog/admin 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/admin.module.d.ts +3 -0
- package/dist/admin.module.d.ts.map +1 -0
- package/dist/admin.module.js +34 -0
- package/dist/admin.module.js.map +1 -0
- package/dist/auth/auth.controller.d.ts +21 -0
- package/dist/auth/auth.controller.d.ts.map +1 -0
- package/dist/auth/auth.controller.js +77 -0
- package/dist/auth/auth.controller.js.map +1 -0
- package/dist/auth/auth.module.d.ts +3 -0
- package/dist/auth/auth.module.d.ts.map +1 -0
- package/dist/auth/auth.module.js +50 -0
- package/dist/auth/auth.module.js.map +1 -0
- package/dist/auth/auth.service.d.ts +36 -0
- package/dist/auth/auth.service.d.ts.map +1 -0
- package/dist/auth/auth.service.js +162 -0
- package/dist/auth/auth.service.js.map +1 -0
- package/dist/auth/auth.service.spec.d.ts +2 -0
- package/dist/auth/auth.service.spec.d.ts.map +1 -0
- package/dist/auth/auth.service.spec.js +17 -0
- package/dist/auth/auth.service.spec.js.map +1 -0
- package/dist/auth/decorators/public.decorator.d.ts +3 -0
- package/dist/auth/decorators/public.decorator.d.ts.map +1 -0
- package/dist/auth/decorators/public.decorator.js +8 -0
- package/dist/auth/decorators/public.decorator.js.map +1 -0
- package/dist/auth/decorators/user.decorator.d.ts +2 -0
- package/dist/auth/decorators/user.decorator.d.ts.map +1 -0
- package/dist/auth/decorators/user.decorator.js +12 -0
- package/dist/auth/decorators/user.decorator.js.map +1 -0
- package/dist/auth/dto/forget.dto.d.ts +4 -0
- package/dist/auth/dto/forget.dto.d.ts.map +1 -0
- package/dist/auth/dto/forget.dto.js +21 -0
- package/dist/auth/dto/forget.dto.js.map +1 -0
- package/dist/auth/dto/login.dto.d.ts +5 -0
- package/dist/auth/dto/login.dto.d.ts.map +1 -0
- package/dist/auth/dto/login.dto.js +31 -0
- package/dist/auth/dto/login.dto.js.map +1 -0
- package/dist/auth/dto/otp.dto.d.ts +5 -0
- package/dist/auth/dto/otp.dto.d.ts.map +1 -0
- package/dist/auth/dto/otp.dto.js +27 -0
- package/dist/auth/dto/otp.dto.js.map +1 -0
- package/dist/auth/enums/multifactor-type.enum.d.ts +5 -0
- package/dist/auth/enums/multifactor-type.enum.d.ts.map +1 -0
- package/dist/auth/enums/multifactor-type.enum.js +9 -0
- package/dist/auth/enums/multifactor-type.enum.js.map +1 -0
- package/dist/auth/guards/auth.guard.d.ts +11 -0
- package/dist/auth/guards/auth.guard.d.ts.map +1 -0
- package/dist/auth/guards/auth.guard.js +56 -0
- package/dist/auth/guards/auth.guard.js.map +1 -0
- package/dist/auth/migrations/index.d.ts +6 -0
- package/dist/auth/migrations/index.d.ts.map +1 -0
- package/dist/auth/migrations/index.js +121 -0
- package/dist/auth/migrations/index.js.map +1 -0
- package/dist/auth/types/user.type.d.ts +9 -0
- package/dist/auth/types/user.type.d.ts.map +1 -0
- package/dist/auth/types/user.type.js +3 -0
- package/dist/auth/types/user.type.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/menu/dto/create.dto.d.ts +8 -0
- package/dist/menu/dto/create.dto.d.ts.map +1 -0
- package/dist/menu/dto/create.dto.js +44 -0
- package/dist/menu/dto/create.dto.js.map +1 -0
- package/dist/menu/dto/delete.dto.d.ts +4 -0
- package/dist/menu/dto/delete.dto.d.ts.map +1 -0
- package/dist/menu/dto/delete.dto.js +24 -0
- package/dist/menu/dto/delete.dto.js.map +1 -0
- package/dist/menu/dto/order.dto.d.ts +4 -0
- package/dist/menu/dto/order.dto.d.ts.map +1 -0
- package/dist/menu/dto/order.dto.js +23 -0
- package/dist/menu/dto/order.dto.js.map +1 -0
- package/dist/menu/dto/update.dto.d.ts +7 -0
- package/dist/menu/dto/update.dto.d.ts.map +1 -0
- package/dist/menu/dto/update.dto.js +37 -0
- package/dist/menu/dto/update.dto.js.map +1 -0
- package/dist/menu/menu.controller.d.ts +19 -0
- package/dist/menu/menu.controller.d.ts.map +1 -0
- package/dist/menu/menu.controller.js +119 -0
- package/dist/menu/menu.controller.js.map +1 -0
- package/dist/menu/menu.module.d.ts +3 -0
- package/dist/menu/menu.module.d.ts.map +1 -0
- package/dist/menu/menu.module.js +33 -0
- package/dist/menu/menu.module.js.map +1 -0
- package/dist/menu/menu.service.d.ts +23 -0
- package/dist/menu/menu.service.d.ts.map +1 -0
- package/dist/menu/menu.service.js +117 -0
- package/dist/menu/menu.service.js.map +1 -0
- package/dist/menu/migrations/index.d.ts +7 -0
- package/dist/menu/migrations/index.d.ts.map +1 -0
- package/dist/menu/migrations/index.js +101 -0
- package/dist/menu/migrations/index.js.map +1 -0
- package/dist/permission/decorators/permission.decorator.d.ts +3 -0
- package/dist/permission/decorators/permission.decorator.d.ts.map +1 -0
- package/dist/permission/decorators/permission.decorator.js +8 -0
- package/dist/permission/decorators/permission.decorator.js.map +1 -0
- package/dist/permission/dto/create.dto.d.ts +5 -0
- package/dist/permission/dto/create.dto.d.ts.map +1 -0
- package/dist/permission/dto/create.dto.js +27 -0
- package/dist/permission/dto/create.dto.js.map +1 -0
- package/dist/permission/dto/delete.dto.d.ts +4 -0
- package/dist/permission/dto/delete.dto.d.ts.map +1 -0
- package/dist/permission/dto/delete.dto.js +23 -0
- package/dist/permission/dto/delete.dto.js.map +1 -0
- package/dist/permission/dto/update.dto.d.ts +5 -0
- package/dist/permission/dto/update.dto.d.ts.map +1 -0
- package/dist/permission/dto/update.dto.js +27 -0
- package/dist/permission/dto/update.dto.js.map +1 -0
- package/dist/permission/guards/permission.guard.d.ts +11 -0
- package/dist/permission/guards/permission.guard.d.ts.map +1 -0
- package/dist/permission/guards/permission.guard.js +99 -0
- package/dist/permission/guards/permission.guard.js.map +1 -0
- package/dist/permission/migrations/index.d.ts +6 -0
- package/dist/permission/migrations/index.d.ts.map +1 -0
- package/dist/permission/migrations/index.js +520 -0
- package/dist/permission/migrations/index.js.map +1 -0
- package/dist/permission/permission.controller.d.ts +14 -0
- package/dist/permission/permission.controller.d.ts.map +1 -0
- package/dist/permission/permission.controller.js +95 -0
- package/dist/permission/permission.controller.js.map +1 -0
- package/dist/permission/permission.module.d.ts +3 -0
- package/dist/permission/permission.module.d.ts.map +1 -0
- package/dist/permission/permission.module.js +39 -0
- package/dist/permission/permission.module.js.map +1 -0
- package/dist/permission/permission.service.d.ts +19 -0
- package/dist/permission/permission.service.d.ts.map +1 -0
- package/dist/permission/permission.service.js +73 -0
- package/dist/permission/permission.service.js.map +1 -0
- package/dist/permission/types/permission.types.d.ts +33 -0
- package/dist/permission/types/permission.types.d.ts.map +1 -0
- package/dist/permission/types/permission.types.js +3 -0
- package/dist/permission/types/permission.types.js.map +1 -0
- package/dist/screen/dto/create.dto.d.ts +7 -0
- package/dist/screen/dto/create.dto.d.ts.map +1 -0
- package/dist/screen/dto/create.dto.js +37 -0
- package/dist/screen/dto/create.dto.js.map +1 -0
- package/dist/screen/dto/delete.dto.d.ts +4 -0
- package/dist/screen/dto/delete.dto.d.ts.map +1 -0
- package/dist/screen/dto/delete.dto.js +23 -0
- package/dist/screen/dto/delete.dto.js.map +1 -0
- package/dist/screen/dto/update.dto.d.ts +7 -0
- package/dist/screen/dto/update.dto.d.ts.map +1 -0
- package/dist/screen/dto/update.dto.js +37 -0
- package/dist/screen/dto/update.dto.js.map +1 -0
- package/dist/screen/migrations/index.d.ts +6 -0
- package/dist/screen/migrations/index.d.ts.map +1 -0
- package/dist/screen/migrations/index.js +40 -0
- package/dist/screen/migrations/index.js.map +1 -0
- package/dist/screen/screen.controller.d.ts +14 -0
- package/dist/screen/screen.controller.d.ts.map +1 -0
- package/dist/screen/screen.controller.js +95 -0
- package/dist/screen/screen.controller.js.map +1 -0
- package/dist/screen/screen.module.d.ts +3 -0
- package/dist/screen/screen.module.d.ts.map +1 -0
- package/dist/screen/screen.module.js +31 -0
- package/dist/screen/screen.module.js.map +1 -0
- package/dist/screen/screen.service.d.ts +19 -0
- package/dist/screen/screen.service.d.ts.map +1 -0
- package/dist/screen/screen.service.js +73 -0
- package/dist/screen/screen.service.js.map +1 -0
- package/dist/user/constants/user.constants.d.ts +2 -0
- package/dist/user/constants/user.constants.d.ts.map +1 -0
- package/dist/user/constants/user.constants.js +5 -0
- package/dist/user/constants/user.constants.js.map +1 -0
- package/dist/user/dto/create.dto.d.ts +6 -0
- package/dist/user/dto/create.dto.d.ts.map +1 -0
- package/dist/user/dto/create.dto.js +37 -0
- package/dist/user/dto/create.dto.js.map +1 -0
- package/dist/user/dto/delete.dto.d.ts +4 -0
- package/dist/user/dto/delete.dto.d.ts.map +1 -0
- package/dist/user/dto/delete.dto.js +23 -0
- package/dist/user/dto/delete.dto.js.map +1 -0
- package/dist/user/dto/update.dto.d.ts +8 -0
- package/dist/user/dto/update.dto.d.ts.map +1 -0
- package/dist/user/dto/update.dto.js +50 -0
- package/dist/user/dto/update.dto.js.map +1 -0
- package/dist/user/user.controller.d.ts +14 -0
- package/dist/user/user.controller.d.ts.map +1 -0
- package/dist/user/user.controller.js +95 -0
- package/dist/user/user.controller.js.map +1 -0
- package/dist/user/user.module.d.ts +3 -0
- package/dist/user/user.module.d.ts.map +1 -0
- package/dist/user/user.module.js +31 -0
- package/dist/user/user.module.js.map +1 -0
- package/dist/user/user.service.d.ts +20 -0
- package/dist/user/user.service.d.ts.map +1 -0
- package/dist/user/user.service.js +84 -0
- package/dist/user/user.service.js.map +1 -0
- package/dist/user/user.service.spec.d.ts +2 -0
- package/dist/user/user.service.spec.d.ts.map +1 -0
- package/dist/user/user.service.spec.js +17 -0
- package/dist/user/user.service.spec.js.map +1 -0
- package/package.json +2 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"admin.module.d.ts","sourceRoot":"","sources":["../src/admin.module.ts"],"names":[],"mappings":"AASA,qBAWa,WAAW;CAAG"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
9
|
+
exports.AdminModule = void 0;
|
10
|
+
const prisma_1 = require("@hedhog/prisma");
|
11
|
+
const pagination_1 = require("@hedhog/pagination");
|
12
|
+
const common_1 = require("@nestjs/common");
|
13
|
+
const auth_module_1 = require("./auth/auth.module");
|
14
|
+
const menu_module_1 = require("./menu/menu.module");
|
15
|
+
const permission_module_1 = require("./permission/permission.module");
|
16
|
+
const screen_module_1 = require("./screen/screen.module");
|
17
|
+
const user_module_1 = require("./user/user.module");
|
18
|
+
let AdminModule = class AdminModule {
|
19
|
+
};
|
20
|
+
exports.AdminModule = AdminModule;
|
21
|
+
exports.AdminModule = AdminModule = __decorate([
|
22
|
+
(0, common_1.Module)({
|
23
|
+
imports: [
|
24
|
+
(0, common_1.forwardRef)(() => auth_module_1.AuthModule),
|
25
|
+
(0, common_1.forwardRef)(() => menu_module_1.MenuModule),
|
26
|
+
(0, common_1.forwardRef)(() => pagination_1.PaginationModule),
|
27
|
+
(0, common_1.forwardRef)(() => permission_module_1.PermissionModule),
|
28
|
+
(0, common_1.forwardRef)(() => prisma_1.PrismaModule),
|
29
|
+
(0, common_1.forwardRef)(() => screen_module_1.ScreenModule),
|
30
|
+
(0, common_1.forwardRef)(() => user_module_1.UserModule),
|
31
|
+
],
|
32
|
+
})
|
33
|
+
], AdminModule);
|
34
|
+
//# sourceMappingURL=admin.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"admin.module.js","sourceRoot":"","sources":["../src/admin.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA8C;AAC9C,mDAAsD;AACtD,2CAAoD;AACpD,oDAAgD;AAChD,oDAAgD;AAChD,sEAAkE;AAClE,0DAAsD;AACtD,oDAAgD;AAazC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAXvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6BAAgB,CAAC;YAClC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,oCAAgB,CAAC;YAClC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,qBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,4BAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;SAC7B;KACF,CAAC;GACW,WAAW,CAAG"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { AuthService } from './auth.service';
|
2
|
+
import { ForgetDTO } from './dto/forget.dto';
|
3
|
+
import { LoginDTO } from './dto/login.dto';
|
4
|
+
import { OtpDTO } from './dto/otp.dto';
|
5
|
+
import { User as UserType } from './types/user.type';
|
6
|
+
export declare class AuthController {
|
7
|
+
private readonly service;
|
8
|
+
constructor(service: AuthService);
|
9
|
+
verify({ id }: UserType): Promise<any>;
|
10
|
+
login({ email, password }: LoginDTO): Promise<{
|
11
|
+
token: string;
|
12
|
+
} | {
|
13
|
+
token: string;
|
14
|
+
mfa: boolean;
|
15
|
+
}>;
|
16
|
+
otp({ token, code }: OtpDTO): Promise<{
|
17
|
+
token: string;
|
18
|
+
}>;
|
19
|
+
forget({ email }: ForgetDTO): Promise<boolean>;
|
20
|
+
}
|
21
|
+
//# sourceMappingURL=auth.controller.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.controller.d.ts","sourceRoot":"","sources":["../../src/auth/auth.controller.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAErD,qBACa,cAAc;IAGvB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,WAAW;IAIjC,MAAM,CAAS,EAAE,EAAE,EAAE,EAAE,QAAQ;IAM/B,KAAK,CAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,QAAQ;;;;;;IAM3C,GAAG,CAAS,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM;;;IAMnC,MAAM,CAAS,EAAE,KAAK,EAAE,EAAE,SAAS;CAG1C"}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.AuthController = void 0;
|
16
|
+
const common_1 = require("@nestjs/common");
|
17
|
+
const auth_service_1 = require("./auth.service");
|
18
|
+
const public_decorator_1 = require("./decorators/public.decorator");
|
19
|
+
const user_decorator_1 = require("./decorators/user.decorator");
|
20
|
+
const forget_dto_1 = require("./dto/forget.dto");
|
21
|
+
const login_dto_1 = require("./dto/login.dto");
|
22
|
+
const otp_dto_1 = require("./dto/otp.dto");
|
23
|
+
let AuthController = class AuthController {
|
24
|
+
constructor(service) {
|
25
|
+
this.service = service;
|
26
|
+
}
|
27
|
+
async verify({ id }) {
|
28
|
+
return this.service.verify(id);
|
29
|
+
}
|
30
|
+
async login({ email, password }) {
|
31
|
+
return this.service.login({ email, password });
|
32
|
+
}
|
33
|
+
async otp({ token, code }) {
|
34
|
+
return this.service.otp({ token, code });
|
35
|
+
}
|
36
|
+
async forget({ email }) {
|
37
|
+
return this.service.forget({ email });
|
38
|
+
}
|
39
|
+
};
|
40
|
+
exports.AuthController = AuthController;
|
41
|
+
__decorate([
|
42
|
+
(0, common_1.Get)('verify'),
|
43
|
+
__param(0, (0, user_decorator_1.User)()),
|
44
|
+
__metadata("design:type", Function),
|
45
|
+
__metadata("design:paramtypes", [Object]),
|
46
|
+
__metadata("design:returntype", Promise)
|
47
|
+
], AuthController.prototype, "verify", null);
|
48
|
+
__decorate([
|
49
|
+
(0, public_decorator_1.Public)(),
|
50
|
+
(0, common_1.Post)('login'),
|
51
|
+
__param(0, (0, common_1.Body)()),
|
52
|
+
__metadata("design:type", Function),
|
53
|
+
__metadata("design:paramtypes", [login_dto_1.LoginDTO]),
|
54
|
+
__metadata("design:returntype", Promise)
|
55
|
+
], AuthController.prototype, "login", null);
|
56
|
+
__decorate([
|
57
|
+
(0, public_decorator_1.Public)(),
|
58
|
+
(0, common_1.Post)('otp'),
|
59
|
+
__param(0, (0, common_1.Body)()),
|
60
|
+
__metadata("design:type", Function),
|
61
|
+
__metadata("design:paramtypes", [otp_dto_1.OtpDTO]),
|
62
|
+
__metadata("design:returntype", Promise)
|
63
|
+
], AuthController.prototype, "otp", null);
|
64
|
+
__decorate([
|
65
|
+
(0, public_decorator_1.Public)(),
|
66
|
+
(0, common_1.Post)('forget'),
|
67
|
+
__param(0, (0, common_1.Body)()),
|
68
|
+
__metadata("design:type", Function),
|
69
|
+
__metadata("design:paramtypes", [forget_dto_1.ForgetDTO]),
|
70
|
+
__metadata("design:returntype", Promise)
|
71
|
+
], AuthController.prototype, "forget", null);
|
72
|
+
exports.AuthController = AuthController = __decorate([
|
73
|
+
(0, common_1.Controller)('auth'),
|
74
|
+
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => auth_service_1.AuthService))),
|
75
|
+
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
76
|
+
], AuthController);
|
77
|
+
//# sourceMappingURL=auth.controller.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../src/auth/auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAOwB;AACxB,iDAA6C;AAC7C,oEAAuD;AACvD,gEAAmD;AACnD,iDAA6C;AAC7C,+CAA2C;AAC3C,2CAAuC;AAIhC,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAEmB,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IACpC,CAAC;IAGE,AAAN,KAAK,CAAC,MAAM,CAAS,EAAE,EAAE,EAAY;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAIK,AAAN,KAAK,CAAC,KAAK,CAAS,EAAE,KAAK,EAAE,QAAQ,EAAY;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;IAIK,AAAN,KAAK,CAAC,GAAG,CAAS,EAAE,KAAK,EAAE,IAAI,EAAU;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAIK,AAAN,KAAK,CAAC,MAAM,CAAS,EAAE,KAAK,EAAa;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AA5BY,wCAAc;AAOnB;IADL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACA,WAAA,IAAA,qBAAI,GAAE,CAAA;;;;4CAEnB;AAIK;IAFL,IAAA,yBAAM,GAAE;IACR,IAAA,aAAI,EAAC,OAAO,CAAC;IACD,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAsB,oBAAQ;;2CAEhD;AAIK;IAFL,IAAA,yBAAM,GAAE;IACR,IAAA,aAAI,EAAC,KAAK,CAAC;IACD,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAkB,gBAAM;;yCAExC;AAIK;IAFL,IAAA,yBAAM,GAAE;IACR,IAAA,aAAI,EAAC,QAAQ,CAAC;IACD,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAY,sBAAS;;4CAExC;yBA3BU,cAAc;IAD1B,IAAA,mBAAU,EAAC,MAAM,CAAC;IAGd,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC,CAAC,CAAA;qCACZ,0BAAW;GAH5B,cAAc,CA4B1B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.module.d.ts","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":"AASA,qBA6Ba,UAAU;CAAG"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
9
|
+
exports.AuthModule = void 0;
|
10
|
+
const common_1 = require("@nestjs/common");
|
11
|
+
const auth_service_1 = require("./auth.service");
|
12
|
+
const auth_controller_1 = require("./auth.controller");
|
13
|
+
const prisma_1 = require("@hedhog/prisma");
|
14
|
+
const jwt_1 = require("@nestjs/jwt");
|
15
|
+
const core_1 = require("@nestjs/core");
|
16
|
+
const auth_guard_1 = require("./guards/auth.guard");
|
17
|
+
const mail_1 = require("@hedhog/mail");
|
18
|
+
let AuthModule = class AuthModule {
|
19
|
+
};
|
20
|
+
exports.AuthModule = AuthModule;
|
21
|
+
exports.AuthModule = AuthModule = __decorate([
|
22
|
+
(0, common_1.Module)({
|
23
|
+
imports: [
|
24
|
+
(0, common_1.forwardRef)(() => jwt_1.JwtModule.registerAsync({
|
25
|
+
global: true,
|
26
|
+
useFactory: () => {
|
27
|
+
return {
|
28
|
+
secret: String(process.env.JWT_SECRET),
|
29
|
+
global: true,
|
30
|
+
signOptions: {
|
31
|
+
expiresIn: process.env.JWT_EXPIRES_IN || '30d',
|
32
|
+
},
|
33
|
+
};
|
34
|
+
},
|
35
|
+
})),
|
36
|
+
(0, common_1.forwardRef)(() => prisma_1.PrismaModule),
|
37
|
+
(0, common_1.forwardRef)(() => mail_1.MailModule),
|
38
|
+
],
|
39
|
+
controllers: [auth_controller_1.AuthController],
|
40
|
+
providers: [
|
41
|
+
auth_service_1.AuthService,
|
42
|
+
{
|
43
|
+
provide: core_1.APP_GUARD,
|
44
|
+
useClass: auth_guard_1.AuthGuard,
|
45
|
+
},
|
46
|
+
],
|
47
|
+
exports: [auth_service_1.AuthService],
|
48
|
+
})
|
49
|
+
], AuthModule);
|
50
|
+
//# sourceMappingURL=auth.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAoD;AACpD,iDAA6C;AAC7C,uDAAmD;AACnD,2CAA8C;AAC9C,qCAAwC;AACxC,uCAAyC;AACzC,oDAAgD;AAChD,uCAA0C;AA+BnC,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IA7BtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CACd,eAAS,CAAC,aAAa,CAAC;gBACtB,MAAM,EAAE,IAAI;gBACZ,UAAU,EAAE,GAAG,EAAE;oBACf,OAAO;wBACL,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;wBACtC,MAAM,EAAE,IAAI;wBACZ,WAAW,EAAE;4BACX,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,KAAK;yBAC/C;qBACF,CAAC;gBACJ,CAAC;aACF,CAAC,CACH;YACD,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,qBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,iBAAU,CAAC;SAC7B;QACD,WAAW,EAAE,CAAC,gCAAc,CAAC;QAC7B,SAAS,EAAE;YACT,0BAAW;YACX;gBACE,OAAO,EAAE,gBAAS;gBAClB,QAAQ,EAAE,sBAAS;aACpB;SACF;QACD,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,UAAU,CAAG"}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { PrismaService } from '@hedhog/prisma';
|
2
|
+
import { JwtService } from '@nestjs/jwt';
|
3
|
+
import { ForgetDTO } from './dto/forget.dto';
|
4
|
+
import { LoginDTO } from './dto/login.dto';
|
5
|
+
import { OtpDTO } from './dto/otp.dto';
|
6
|
+
import { MailService } from '@hedhog/mail';
|
7
|
+
export declare class AuthService {
|
8
|
+
private readonly prisma;
|
9
|
+
private readonly jwt;
|
10
|
+
private readonly mail;
|
11
|
+
constructor(prisma: PrismaService, jwt: JwtService, mail: MailService);
|
12
|
+
verifyToken(token: string): Promise<any>;
|
13
|
+
generateRandomString(length: number): string;
|
14
|
+
generateRandomNumber(): number;
|
15
|
+
loginWithEmailAndPassword(email: string, password: string): Promise<{
|
16
|
+
token: string;
|
17
|
+
} | {
|
18
|
+
token: string;
|
19
|
+
mfa: boolean;
|
20
|
+
}>;
|
21
|
+
getToken(user: any): Promise<{
|
22
|
+
token: string;
|
23
|
+
}>;
|
24
|
+
forget({ email }: ForgetDTO): Promise<boolean>;
|
25
|
+
otp({ token, code }: OtpDTO): Promise<{
|
26
|
+
token: string;
|
27
|
+
}>;
|
28
|
+
login({ email, password }: LoginDTO): Promise<{
|
29
|
+
token: string;
|
30
|
+
} | {
|
31
|
+
token: string;
|
32
|
+
mfa: boolean;
|
33
|
+
}>;
|
34
|
+
verify(id: number): any;
|
35
|
+
}
|
36
|
+
//# sourceMappingURL=auth.service.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,qBACa,WAAW;IAGpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAEpB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAJJ,MAAM,EAAE,aAAa,EAErB,GAAG,EAAE,UAAU,EAEf,IAAI,EAAE,WAAW;IAG9B,WAAW,CAAC,KAAK,EAAE,MAAM;IAM/B,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAW5C,oBAAoB,IAAI,MAAM;IAMxB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;IAgDzD,QAAQ,CAAC,IAAI,KAAA;;;IAUb,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS;IAkC3B,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM;;;IA0BjC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,QAAQ;;;;;;IAInC,MAAM,CAAC,EAAE,EAAE,MAAM;CAGlB"}
|
@@ -0,0 +1,162 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.AuthService = void 0;
|
16
|
+
const prisma_1 = require("@hedhog/prisma");
|
17
|
+
const common_1 = require("@nestjs/common");
|
18
|
+
const jwt_1 = require("@nestjs/jwt");
|
19
|
+
const bcrypt_1 = require("bcrypt");
|
20
|
+
const multifactor_type_enum_1 = require("./enums/multifactor-type.enum");
|
21
|
+
const mail_1 = require("@hedhog/mail");
|
22
|
+
let AuthService = class AuthService {
|
23
|
+
constructor(prisma, jwt, mail) {
|
24
|
+
this.prisma = prisma;
|
25
|
+
this.jwt = jwt;
|
26
|
+
this.mail = mail;
|
27
|
+
}
|
28
|
+
async verifyToken(token) {
|
29
|
+
return this.jwt.verifyAsync(token, {
|
30
|
+
secret: String(process.env.JWT_SECRET),
|
31
|
+
});
|
32
|
+
}
|
33
|
+
generateRandomString(length) {
|
34
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
35
|
+
let result = '';
|
36
|
+
for (let i = 0; i < length; i++) {
|
37
|
+
const randomIndex = Math.floor(Math.random() * characters.length);
|
38
|
+
result += characters.charAt(randomIndex);
|
39
|
+
}
|
40
|
+
return result;
|
41
|
+
}
|
42
|
+
generateRandomNumber() {
|
43
|
+
const min = 100000;
|
44
|
+
const max = 999999;
|
45
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
46
|
+
}
|
47
|
+
async loginWithEmailAndPassword(email, password) {
|
48
|
+
const user = await this.prisma.users.findFirst({
|
49
|
+
where: {
|
50
|
+
email,
|
51
|
+
},
|
52
|
+
});
|
53
|
+
if (!user) {
|
54
|
+
throw new common_1.NotFoundException('User not found');
|
55
|
+
}
|
56
|
+
const isPasswordValid = await (0, bcrypt_1.compare)(password, user.password);
|
57
|
+
if (!isPasswordValid) {
|
58
|
+
throw new common_1.NotFoundException('Invalid password');
|
59
|
+
}
|
60
|
+
if (!user.multifactor_id) {
|
61
|
+
return this.getToken(user);
|
62
|
+
}
|
63
|
+
else {
|
64
|
+
if (user.multifactor_id === multifactor_type_enum_1.MultifactorType.EMAIL) {
|
65
|
+
const code = this.generateRandomNumber();
|
66
|
+
await this.prisma.users.update({
|
67
|
+
where: {
|
68
|
+
id: user.id,
|
69
|
+
},
|
70
|
+
data: {
|
71
|
+
code: String(code),
|
72
|
+
},
|
73
|
+
});
|
74
|
+
await this.mail.send({
|
75
|
+
to: user.email,
|
76
|
+
subject: 'Login code',
|
77
|
+
body: `Your login code is ${code}`,
|
78
|
+
});
|
79
|
+
}
|
80
|
+
return {
|
81
|
+
token: this.jwt.sign({
|
82
|
+
id: user.id,
|
83
|
+
mfa: user.multifactor_id,
|
84
|
+
}),
|
85
|
+
mfa: true,
|
86
|
+
};
|
87
|
+
}
|
88
|
+
}
|
89
|
+
async getToken(user) {
|
90
|
+
delete user.password;
|
91
|
+
const payload = { user };
|
92
|
+
return {
|
93
|
+
token: this.jwt.sign(payload),
|
94
|
+
};
|
95
|
+
}
|
96
|
+
async forget({ email }) {
|
97
|
+
const user = await this.prisma.users.findFirst({
|
98
|
+
where: {
|
99
|
+
email,
|
100
|
+
},
|
101
|
+
select: {
|
102
|
+
id: true,
|
103
|
+
},
|
104
|
+
});
|
105
|
+
if (!user) {
|
106
|
+
throw new common_1.NotFoundException('User not found');
|
107
|
+
}
|
108
|
+
const code = this.generateRandomString(32);
|
109
|
+
await this.prisma.users.update({
|
110
|
+
where: {
|
111
|
+
id: user.id,
|
112
|
+
},
|
113
|
+
data: {
|
114
|
+
code,
|
115
|
+
},
|
116
|
+
});
|
117
|
+
await this.mail.send({
|
118
|
+
to: email,
|
119
|
+
subject: 'Reset password',
|
120
|
+
body: `Reset your password by clicking <a href="${process.env.FRONTEND_URL}/reset-password/${code}">here</a>`,
|
121
|
+
});
|
122
|
+
return true;
|
123
|
+
}
|
124
|
+
async otp({ token, code }) {
|
125
|
+
const data = this.jwt.decode(token);
|
126
|
+
const user = await this.prisma.users.findFirst({
|
127
|
+
where: {
|
128
|
+
id: data['id'],
|
129
|
+
code: String(code),
|
130
|
+
},
|
131
|
+
});
|
132
|
+
if (!user) {
|
133
|
+
throw new common_1.NotFoundException('Invalid code');
|
134
|
+
}
|
135
|
+
await this.prisma.users.update({
|
136
|
+
where: {
|
137
|
+
id: user.id,
|
138
|
+
},
|
139
|
+
data: {
|
140
|
+
code: null,
|
141
|
+
},
|
142
|
+
});
|
143
|
+
return this.getToken(user);
|
144
|
+
}
|
145
|
+
login({ email, password }) {
|
146
|
+
return this.loginWithEmailAndPassword(email, password);
|
147
|
+
}
|
148
|
+
verify(id) {
|
149
|
+
return this.prisma.users.findUnique({ where: { id } });
|
150
|
+
}
|
151
|
+
};
|
152
|
+
exports.AuthService = AuthService;
|
153
|
+
exports.AuthService = AuthService = __decorate([
|
154
|
+
(0, common_1.Injectable)(),
|
155
|
+
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => prisma_1.PrismaService))),
|
156
|
+
__param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => jwt_1.JwtService))),
|
157
|
+
__param(2, (0, common_1.Inject)((0, common_1.forwardRef)(() => mail_1.MailService))),
|
158
|
+
__metadata("design:paramtypes", [prisma_1.PrismaService,
|
159
|
+
jwt_1.JwtService,
|
160
|
+
mail_1.MailService])
|
161
|
+
], AuthService);
|
162
|
+
//# sourceMappingURL=auth.service.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+C;AAC/C,2CAKwB;AACxB,qCAAyC;AACzC,mCAAiC;AAIjC,yEAAgE;AAChE,uCAA2C;AAGpC,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAEmB,MAAqB,EAErB,GAAe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,0BAAiB,CAAC,cAAc,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;YAC7B,KAAK,EAAE;gBACL,EAAE,EAAE,IAAI,CAAC,EAAE;aACZ;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,IAAI;aACX;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAY;QACjC,OAAO,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC;CACF,CAAA;AA9JY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,gBAAU,CAAC,CAAC,CAAA;IAEpC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kBAAW,CAAC,CAAC,CAAA;qCAHb,sBAAa;QAEhB,gBAAU;QAET,kBAAW;GAPzB,WAAW,CA8JvB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.service.spec.d.ts","sourceRoot":"","sources":["../../src/auth/auth.service.spec.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const testing_1 = require("@nestjs/testing");
|
4
|
+
const auth_service_1 = require("./auth.service");
|
5
|
+
describe('AuthService', () => {
|
6
|
+
let service;
|
7
|
+
beforeEach(async () => {
|
8
|
+
const module = await testing_1.Test.createTestingModule({
|
9
|
+
providers: [auth_service_1.AuthService],
|
10
|
+
}).compile();
|
11
|
+
service = module.get(auth_service_1.AuthService);
|
12
|
+
});
|
13
|
+
it('should be defined', () => {
|
14
|
+
expect(service).toBeDefined();
|
15
|
+
});
|
16
|
+
});
|
17
|
+
//# sourceMappingURL=auth.service.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.service.spec.js","sourceRoot":"","sources":["../../src/auth/auth.service.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,iDAA6C;AAE7C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,OAAoB,CAAC;IAEzB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE,CAAC,0BAAW,CAAC;SACzB,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,OAAO,GAAG,MAAM,CAAC,GAAG,CAAc,0BAAW,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"public.decorator.d.ts","sourceRoot":"","sources":["../../../src/auth/decorators/public.decorator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,MAAM,wDAAyC,CAAC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Public = exports.IS_PUBLIC_KEY = void 0;
|
4
|
+
const common_1 = require("@nestjs/common");
|
5
|
+
exports.IS_PUBLIC_KEY = 'isPublic';
|
6
|
+
const Public = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
|
7
|
+
exports.Public = Public;
|
8
|
+
//# sourceMappingURL=public.decorator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../../src/auth/decorators/public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,qBAAa,EAAE,IAAI,CAAC,CAAC;AAAhD,QAAA,MAAM,UAA0C"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"user.decorator.d.ts","sourceRoot":"","sources":["../../../src/auth/decorators/user.decorator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,yLAUhB,CAAC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.User = void 0;
|
4
|
+
const common_1 = require("@nestjs/common");
|
5
|
+
exports.User = (0, common_1.createParamDecorator)((field = null, ctx) => {
|
6
|
+
const request = ctx.switchToHttp().getRequest();
|
7
|
+
if (!request.auth || !request.auth.user) {
|
8
|
+
throw new common_1.UnauthorizedException(`User is not authenticated`);
|
9
|
+
}
|
10
|
+
return field ? request.auth.user[field] : request.auth.user;
|
11
|
+
});
|
12
|
+
//# sourceMappingURL=user.decorator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"user.decorator.js","sourceRoot":"","sources":["../../../src/auth/decorators/user.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA+F;AAElF,QAAA,IAAI,GAAG,IAAA,6BAAoB,EACtC,CAAC,QAAuB,IAAI,EAAE,GAAqB,EAAE,EAAE;IACrD,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAEhD,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,8BAAqB,CAAC,2BAA2B,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;AAC9D,CAAC,CACF,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"forget.dto.d.ts","sourceRoot":"","sources":["../../../src/auth/dto/forget.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAGpB,KAAK,EAAE,MAAM,CAAC;CAEf"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.ForgetDTO = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
class ForgetDTO {
|
15
|
+
}
|
16
|
+
exports.ForgetDTO = ForgetDTO;
|
17
|
+
__decorate([
|
18
|
+
(0, class_validator_1.IsEmail)(),
|
19
|
+
__metadata("design:type", String)
|
20
|
+
], ForgetDTO.prototype, "email", void 0);
|
21
|
+
//# sourceMappingURL=forget.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"forget.dto.js","sourceRoot":"","sources":["../../../src/auth/dto/forget.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA0C;AAE1C,MAAa,SAAS;CAKrB;AALD,8BAKC;AAFC;IADC,IAAA,yBAAO,GAAE;;wCACI"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"login.dto.d.ts","sourceRoot":"","sources":["../../../src/auth/dto/login.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,QAAQ;IAEnB,KAAK,EAAE,MAAM,CAAC;IASd,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.LoginDTO = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
class LoginDTO {
|
15
|
+
}
|
16
|
+
exports.LoginDTO = LoginDTO;
|
17
|
+
__decorate([
|
18
|
+
(0, class_validator_1.IsEmail)(),
|
19
|
+
__metadata("design:type", String)
|
20
|
+
], LoginDTO.prototype, "email", void 0);
|
21
|
+
__decorate([
|
22
|
+
(0, class_validator_1.IsStrongPassword)({
|
23
|
+
minLength: 6,
|
24
|
+
minLowercase: 1,
|
25
|
+
minUppercase: 0,
|
26
|
+
minNumbers: 0,
|
27
|
+
minSymbols: 0,
|
28
|
+
}),
|
29
|
+
__metadata("design:type", String)
|
30
|
+
], LoginDTO.prototype, "password", void 0);
|
31
|
+
//# sourceMappingURL=login.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"login.dto.js","sourceRoot":"","sources":["../../../src/auth/dto/login.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA4D;AAE5D,MAAa,QAAQ;CAYpB;AAZD,4BAYC;AAVC;IADC,IAAA,yBAAO,GAAE;;uCACI;AASd;IAPC,IAAA,kCAAgB,EAAC;QAChB,SAAS,EAAE,CAAC;QACZ,YAAY,EAAE,CAAC;QACf,YAAY,EAAE,CAAC;QACf,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,CAAC;KACd,CAAC;;0CACe"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"otp.dto.d.ts","sourceRoot":"","sources":["../../../src/auth/dto/otp.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,MAAM;IAKjB,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;CAEf"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.OtpDTO = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
class OtpDTO {
|
15
|
+
}
|
16
|
+
exports.OtpDTO = OtpDTO;
|
17
|
+
__decorate([
|
18
|
+
(0, class_validator_1.Min)(0),
|
19
|
+
(0, class_validator_1.Max)(999999),
|
20
|
+
(0, class_validator_1.IsInt)(),
|
21
|
+
__metadata("design:type", Number)
|
22
|
+
], OtpDTO.prototype, "code", void 0);
|
23
|
+
__decorate([
|
24
|
+
(0, class_validator_1.IsJWT)(),
|
25
|
+
__metadata("design:type", String)
|
26
|
+
], OtpDTO.prototype, "token", void 0);
|
27
|
+
//# sourceMappingURL=otp.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"otp.dto.js","sourceRoot":"","sources":["../../../src/auth/dto/otp.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAyD;AAEzD,MAAa,MAAM;CAUlB;AAVD,wBAUC;AALC;IAHC,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,qBAAG,EAAC,MAAM,CAAC;IACX,IAAA,uBAAK,GAAE;;oCACK;AAGb;IADC,IAAA,uBAAK,GAAE;;qCACM"}
|