@ofeklabs/horizon-auth 0.2.0 → 0.3.0
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/account/account.module.d.ts +2 -0
- package/dist/account/account.module.js +23 -0
- package/dist/account/account.module.js.map +1 -0
- package/dist/account/account.service.d.ts +10 -0
- package/dist/account/account.service.js +69 -0
- package/dist/account/account.service.js.map +1 -0
- package/dist/account/dto/deactivate-account.dto.d.ts +3 -0
- package/dist/account/dto/deactivate-account.dto.js +22 -0
- package/dist/account/dto/deactivate-account.dto.js.map +1 -0
- package/dist/account/dto/index.d.ts +1 -0
- package/dist/account/dto/index.js +18 -0
- package/dist/account/dto/index.js.map +1 -0
- package/dist/auth/auth.controller.d.ts +81 -2
- package/dist/auth/auth.controller.js +304 -6
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/auth.module.d.ts +4 -0
- package/dist/auth/auth.module.js +64 -18
- package/dist/auth/auth.module.js.map +1 -1
- package/dist/auth/auth.service.d.ts +19 -2
- package/dist/auth/auth.service.js +85 -3
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/strategies/jwt-sso.strategy.d.ts +8 -0
- package/dist/auth/strategies/jwt-sso.strategy.js +46 -0
- package/dist/auth/strategies/jwt-sso.strategy.js.map +1 -0
- package/dist/common/exceptions/account-deactivated.exception.d.ts +4 -0
- package/dist/common/exceptions/account-deactivated.exception.js +13 -0
- package/dist/common/exceptions/account-deactivated.exception.js.map +1 -0
- package/dist/common/exceptions/backup-code-already-used.exception.d.ts +4 -0
- package/dist/common/exceptions/backup-code-already-used.exception.js +11 -0
- package/dist/common/exceptions/backup-code-already-used.exception.js.map +1 -0
- package/dist/common/exceptions/feature-disabled.exception.d.ts +4 -0
- package/dist/common/exceptions/feature-disabled.exception.js +11 -0
- package/dist/common/exceptions/feature-disabled.exception.js.map +1 -0
- package/dist/common/exceptions/index.d.ts +6 -0
- package/dist/common/exceptions/index.js +23 -0
- package/dist/common/exceptions/index.js.map +1 -0
- package/dist/common/exceptions/invalid-two-factor-code.exception.d.ts +4 -0
- package/dist/common/exceptions/invalid-two-factor-code.exception.js +11 -0
- package/dist/common/exceptions/invalid-two-factor-code.exception.js.map +1 -0
- package/dist/common/exceptions/social-account-already-linked.exception.d.ts +4 -0
- package/dist/common/exceptions/social-account-already-linked.exception.js +11 -0
- package/dist/common/exceptions/social-account-already-linked.exception.js.map +1 -0
- package/dist/common/exceptions/two-factor-required.exception.d.ts +5 -0
- package/dist/common/exceptions/two-factor-required.exception.js +12 -0
- package/dist/common/exceptions/two-factor-required.exception.js.map +1 -0
- package/dist/devices/device.module.d.ts +2 -0
- package/dist/devices/device.module.js +24 -0
- package/dist/devices/device.module.js.map +1 -0
- package/dist/devices/device.service.d.ts +48 -0
- package/dist/devices/device.service.js +149 -0
- package/dist/devices/device.service.js.map +1 -0
- package/dist/devices/dto/device-info.dto.d.ts +3 -0
- package/dist/devices/dto/device-info.dto.js +22 -0
- package/dist/devices/dto/device-info.dto.js.map +1 -0
- package/dist/devices/dto/device-response.dto.d.ts +9 -0
- package/dist/devices/dto/device-response.dto.js +7 -0
- package/dist/devices/dto/device-response.dto.js.map +1 -0
- package/dist/devices/dto/index.d.ts +2 -0
- package/dist/devices/dto/index.js +19 -0
- package/dist/devices/dto/index.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/horizon-auth-config.interface.d.ts +29 -0
- package/dist/lib/horizon-auth.module.js +3 -3
- package/dist/lib/horizon-auth.module.js.map +1 -1
- package/dist/push-tokens/dto/index.d.ts +1 -0
- package/dist/push-tokens/dto/index.js +18 -0
- package/dist/push-tokens/dto/index.js.map +1 -0
- package/dist/push-tokens/dto/register-push-token.dto.d.ts +5 -0
- package/dist/push-tokens/dto/register-push-token.dto.js +30 -0
- package/dist/push-tokens/dto/register-push-token.dto.js.map +1 -0
- package/dist/push-tokens/push-token.module.d.ts +2 -0
- package/dist/push-tokens/push-token.module.js +24 -0
- package/dist/push-tokens/push-token.module.js.map +1 -0
- package/dist/push-tokens/push-token.service.d.ts +52 -0
- package/dist/push-tokens/push-token.service.js +129 -0
- package/dist/push-tokens/push-token.service.js.map +1 -0
- package/dist/social-auth/dto/facebook-callback.dto.d.ts +3 -0
- package/dist/social-auth/dto/facebook-callback.dto.js +22 -0
- package/dist/social-auth/dto/facebook-callback.dto.js.map +1 -0
- package/dist/social-auth/dto/google-callback.dto.d.ts +3 -0
- package/dist/social-auth/dto/google-callback.dto.js +22 -0
- package/dist/social-auth/dto/google-callback.dto.js.map +1 -0
- package/dist/social-auth/dto/index.d.ts +2 -0
- package/dist/social-auth/dto/index.js +19 -0
- package/dist/social-auth/dto/index.js.map +1 -0
- package/dist/social-auth/social-auth.module.d.ts +2 -0
- package/dist/social-auth/social-auth.module.js +25 -0
- package/dist/social-auth/social-auth.module.js.map +1 -0
- package/dist/social-auth/social-auth.service.d.ts +43 -0
- package/dist/social-auth/social-auth.service.js +130 -0
- package/dist/social-auth/social-auth.service.js.map +1 -0
- package/dist/social-auth/strategies/facebook.strategy.d.ts +9 -0
- package/dist/social-auth/strategies/facebook.strategy.js +51 -0
- package/dist/social-auth/strategies/facebook.strategy.js.map +1 -0
- package/dist/social-auth/strategies/google.strategy.d.ts +9 -0
- package/dist/social-auth/strategies/google.strategy.js +49 -0
- package/dist/social-auth/strategies/google.strategy.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/two-factor/dto/enable-two-factor.dto.d.ts +2 -0
- package/dist/two-factor/dto/enable-two-factor.dto.js +7 -0
- package/dist/two-factor/dto/enable-two-factor.dto.js.map +1 -0
- package/dist/two-factor/dto/index.d.ts +2 -0
- package/dist/two-factor/dto/index.js +19 -0
- package/dist/two-factor/dto/index.js.map +1 -0
- package/dist/two-factor/dto/two-factor-enabled-response.dto.d.ts +3 -0
- package/dist/two-factor/dto/two-factor-enabled-response.dto.js +7 -0
- package/dist/two-factor/dto/two-factor-enabled-response.dto.js.map +1 -0
- package/dist/two-factor/dto/two-factor-setup-response.dto.d.ts +4 -0
- package/dist/two-factor/dto/two-factor-setup-response.dto.js +7 -0
- package/dist/two-factor/dto/two-factor-setup-response.dto.js.map +1 -0
- package/dist/two-factor/dto/verify-two-factor-login.dto.d.ts +3 -0
- package/dist/two-factor/dto/verify-two-factor-login.dto.js +22 -0
- package/dist/two-factor/dto/verify-two-factor-login.dto.js.map +1 -0
- package/dist/two-factor/dto/verify-two-factor-setup.dto.d.ts +3 -0
- package/dist/two-factor/dto/verify-two-factor-setup.dto.js +22 -0
- package/dist/two-factor/dto/verify-two-factor-setup.dto.js.map +1 -0
- package/dist/two-factor/two-factor.module.d.ts +2 -0
- package/dist/two-factor/two-factor.module.js +23 -0
- package/dist/two-factor/two-factor.module.js.map +1 -0
- package/dist/two-factor/two-factor.service.d.ts +19 -0
- package/dist/two-factor/two-factor.service.js +215 -0
- package/dist/two-factor/two-factor.service.js.map +1 -0
- package/dist/users/users.service.d.ts +1 -1
- package/dist/users/users.service.js.map +1 -1
- package/package.json +23 -4
- package/prisma/migrations/20260218105110_add_enhanced_auth_features/migration.sql +192 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +106 -13
|
@@ -0,0 +1,23 @@
|
|
|
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.AccountModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const account_service_1 = require("./account.service");
|
|
12
|
+
const prisma_module_1 = require("../prisma/prisma.module");
|
|
13
|
+
let AccountModule = class AccountModule {
|
|
14
|
+
};
|
|
15
|
+
exports.AccountModule = AccountModule;
|
|
16
|
+
exports.AccountModule = AccountModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
imports: [prisma_module_1.PrismaModule],
|
|
19
|
+
providers: [account_service_1.AccountService],
|
|
20
|
+
exports: [account_service_1.AccountService],
|
|
21
|
+
})
|
|
22
|
+
], AccountModule);
|
|
23
|
+
//# sourceMappingURL=account.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.module.js","sourceRoot":"","sources":["../../src/account/account.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,uDAAmD;AACnD,2DAAuD;AAOhD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IALzB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,SAAS,EAAE,CAAC,gCAAc,CAAC;QAC3B,OAAO,EAAE,CAAC,gCAAc,CAAC;KAC1B,CAAC;GACW,aAAa,CAAG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PrismaService } from '../prisma/prisma.service';
|
|
2
|
+
export declare class AccountService {
|
|
3
|
+
private readonly prisma;
|
|
4
|
+
constructor(prisma: PrismaService);
|
|
5
|
+
deactivateAccount(userId: string, reason?: string): Promise<void>;
|
|
6
|
+
reactivateAccount(userId: string): Promise<void>;
|
|
7
|
+
reactivateAccountByEmail(email: string): Promise<string>;
|
|
8
|
+
deleteAccount(userId: string): Promise<void>;
|
|
9
|
+
isAccountActive(userId: string): Promise<boolean>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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.AccountService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const prisma_service_1 = require("../prisma/prisma.service");
|
|
15
|
+
let AccountService = class AccountService {
|
|
16
|
+
constructor(prisma) {
|
|
17
|
+
this.prisma = prisma;
|
|
18
|
+
}
|
|
19
|
+
async deactivateAccount(userId, reason) {
|
|
20
|
+
await this.prisma.refreshToken.updateMany({
|
|
21
|
+
where: { userId, revoked: false },
|
|
22
|
+
data: { revoked: true },
|
|
23
|
+
});
|
|
24
|
+
await this.prisma.user.update({
|
|
25
|
+
where: { id: userId },
|
|
26
|
+
data: {
|
|
27
|
+
isActive: false,
|
|
28
|
+
deactivationReason: reason,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async reactivateAccount(userId) {
|
|
33
|
+
await this.prisma.user.update({
|
|
34
|
+
where: { id: userId },
|
|
35
|
+
data: {
|
|
36
|
+
isActive: true,
|
|
37
|
+
deactivationReason: null,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async reactivateAccountByEmail(email) {
|
|
42
|
+
const user = await this.prisma.user.findUnique({
|
|
43
|
+
where: { email },
|
|
44
|
+
});
|
|
45
|
+
if (!user) {
|
|
46
|
+
throw new Error('User not found');
|
|
47
|
+
}
|
|
48
|
+
await this.reactivateAccount(user.id);
|
|
49
|
+
return user.id;
|
|
50
|
+
}
|
|
51
|
+
async deleteAccount(userId) {
|
|
52
|
+
await this.prisma.user.delete({
|
|
53
|
+
where: { id: userId },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async isAccountActive(userId) {
|
|
57
|
+
const user = await this.prisma.user.findUnique({
|
|
58
|
+
where: { id: userId },
|
|
59
|
+
select: { isActive: true },
|
|
60
|
+
});
|
|
61
|
+
return user?.isActive ?? false;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.AccountService = AccountService;
|
|
65
|
+
exports.AccountService = AccountService = __decorate([
|
|
66
|
+
(0, common_1.Injectable)(),
|
|
67
|
+
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
|
68
|
+
], AccountService);
|
|
69
|
+
//# sourceMappingURL=account.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.service.js","sourceRoot":"","sources":["../../src/account/account.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6DAAyD;AAGlD,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAKtD,KAAK,CAAC,iBAAiB,CAAC,MAAc,EAAE,MAAe;QAErD,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC;YACxC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE;YACjC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SACxB,CAAC,CAAC;QAGH,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YAC5B,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACrB,IAAI,EAAE;gBACJ,QAAQ,EAAE,KAAK;gBACf,kBAAkB,EAAE,MAAM;aAC3B;SACF,CAAC,CAAC;IACL,CAAC;IAKD,KAAK,CAAC,iBAAiB,CAAC,MAAc;QACpC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YAC5B,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACrB,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI;gBACd,kBAAkB,EAAE,IAAI;aACzB;SACF,CAAC,CAAC;IACL,CAAC;IAKD,KAAK,CAAC,wBAAwB,CAAC,KAAa;QAC1C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YAC7C,KAAK,EAAE,EAAE,KAAK,EAAE;SACjB,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAKD,KAAK,CAAC,aAAa,CAAC,MAAc;QAEhC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YAC5B,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;SACtB,CAAC,CAAC;IACL,CAAC;IAKD,KAAK,CAAC,eAAe,CAAC,MAAc;QAClC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YAC7C,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACrB,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC3B,CAAC,CAAC;QAEH,OAAO,IAAI,EAAE,QAAQ,IAAI,KAAK,CAAC;IACjC,CAAC;CACF,CAAA;AAzEY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAE0B,8BAAa;GADvC,cAAc,CAyE1B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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.DeactivateAccountDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class DeactivateAccountDto {
|
|
15
|
+
}
|
|
16
|
+
exports.DeactivateAccountDto = DeactivateAccountDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsOptional)(),
|
|
19
|
+
(0, class_validator_1.IsString)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], DeactivateAccountDto.prototype, "reason", void 0);
|
|
22
|
+
//# sourceMappingURL=deactivate-account.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deactivate-account.dto.js","sourceRoot":"","sources":["../../../src/account/dto/deactivate-account.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,oBAAoB;CAIhC;AAJD,oDAIC;AADC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './deactivate-account.dto';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./deactivate-account.dto"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/account/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|
|
@@ -4,16 +4,37 @@ import { RegisterDto } from './dto/register.dto';
|
|
|
4
4
|
import { LoginDto } from './dto/login.dto';
|
|
5
5
|
import { RequestPasswordResetDto, ResetPasswordDto, VerifyEmailDto } from './dto/password-reset.dto';
|
|
6
6
|
import { SafeUser } from '../users/users.service';
|
|
7
|
+
import { TwoFactorService } from '../two-factor/two-factor.service';
|
|
8
|
+
import { VerifyTwoFactorSetupDto } from '../two-factor/dto/verify-two-factor-setup.dto';
|
|
9
|
+
import { AccountService } from '../account/account.service';
|
|
10
|
+
import { DeactivateAccountDto } from '../account/dto/deactivate-account.dto';
|
|
11
|
+
import { SocialAuthService } from '../social-auth/social-auth.service';
|
|
12
|
+
import { GoogleCallbackDto, FacebookCallbackDto } from '../social-auth/dto';
|
|
13
|
+
import { PushTokenService } from '../push-tokens/push-token.service';
|
|
14
|
+
import { RegisterPushTokenDto } from '../push-tokens/dto/register-push-token.dto';
|
|
15
|
+
import { DeviceService } from '../devices/device.service';
|
|
7
16
|
export declare class AuthController {
|
|
8
17
|
private readonly authService;
|
|
9
|
-
|
|
18
|
+
private readonly twoFactorService?;
|
|
19
|
+
private readonly accountService?;
|
|
20
|
+
private readonly socialAuthService?;
|
|
21
|
+
private readonly pushTokenService?;
|
|
22
|
+
private readonly deviceService?;
|
|
23
|
+
constructor(authService: AuthService, twoFactorService?: TwoFactorService | undefined, accountService?: AccountService | undefined, socialAuthService?: SocialAuthService | undefined, pushTokenService?: PushTokenService | undefined, deviceService?: DeviceService | undefined);
|
|
10
24
|
register(registerDto: RegisterDto, response: Response): Promise<{
|
|
11
25
|
user: SafeUser;
|
|
12
26
|
accessToken: string;
|
|
13
27
|
}>;
|
|
14
|
-
login(loginDto: LoginDto, response: Response): Promise<{
|
|
28
|
+
login(loginDto: LoginDto, request: Request, response: Response): Promise<{
|
|
29
|
+
requiresTwoFactor: boolean;
|
|
30
|
+
userId: string;
|
|
31
|
+
user?: undefined;
|
|
32
|
+
accessToken?: undefined;
|
|
33
|
+
} | {
|
|
15
34
|
user: SafeUser;
|
|
16
35
|
accessToken: string;
|
|
36
|
+
requiresTwoFactor?: undefined;
|
|
37
|
+
userId?: undefined;
|
|
17
38
|
}>;
|
|
18
39
|
refresh(request: Request, response: Response): Promise<{
|
|
19
40
|
user: SafeUser;
|
|
@@ -32,5 +53,63 @@ export declare class AuthController {
|
|
|
32
53
|
verifyEmail(dto: VerifyEmailDto): Promise<{
|
|
33
54
|
message: string;
|
|
34
55
|
}>;
|
|
56
|
+
verifyTwoFactorLogin(dto: {
|
|
57
|
+
userId: string;
|
|
58
|
+
code: string;
|
|
59
|
+
}, request: Request, response: Response): Promise<{
|
|
60
|
+
user: SafeUser;
|
|
61
|
+
accessToken: string;
|
|
62
|
+
}>;
|
|
63
|
+
enableTwoFactor(user: SafeUser): Promise<{
|
|
64
|
+
secret: string;
|
|
65
|
+
qrCode: string;
|
|
66
|
+
}>;
|
|
67
|
+
verifyTwoFactorSetup(user: SafeUser, dto: VerifyTwoFactorSetupDto): Promise<{
|
|
68
|
+
backupCodes: string[];
|
|
69
|
+
}>;
|
|
70
|
+
disableTwoFactor(user: SafeUser): Promise<{
|
|
71
|
+
message: string;
|
|
72
|
+
}>;
|
|
73
|
+
regenerateBackupCodes(user: SafeUser): Promise<{
|
|
74
|
+
backupCodes: string[];
|
|
75
|
+
}>;
|
|
76
|
+
googleCallback(dto: GoogleCallbackDto, response: Response): Promise<void>;
|
|
77
|
+
facebookCallback(dto: FacebookCallbackDto, response: Response): Promise<void>;
|
|
78
|
+
registerPushToken(user: SafeUser, dto: RegisterPushTokenDto): Promise<{
|
|
79
|
+
id: string;
|
|
80
|
+
createdAt: Date;
|
|
81
|
+
updatedAt: Date;
|
|
82
|
+
userId: string;
|
|
83
|
+
token: string;
|
|
84
|
+
deviceId: string;
|
|
85
|
+
tokenType: string;
|
|
86
|
+
active: boolean;
|
|
87
|
+
}>;
|
|
88
|
+
revokePushToken(user: SafeUser, tokenId: string): Promise<{
|
|
89
|
+
message: string;
|
|
90
|
+
}>;
|
|
91
|
+
getDevices(user: SafeUser, request: Request): Promise<import("../devices/device.service").DeviceResponse[]>;
|
|
92
|
+
revokeDevice(user: SafeUser, deviceId: string): Promise<{
|
|
93
|
+
message: string;
|
|
94
|
+
}>;
|
|
95
|
+
deactivateAccount(user: SafeUser, dto: DeactivateAccountDto, response: Response): Promise<{
|
|
96
|
+
message: string;
|
|
97
|
+
}>;
|
|
98
|
+
reactivateAccount(dto: {
|
|
99
|
+
email: string;
|
|
100
|
+
password: string;
|
|
101
|
+
}): Promise<{
|
|
102
|
+
user: SafeUser;
|
|
103
|
+
accessToken: string;
|
|
104
|
+
refreshToken: string;
|
|
105
|
+
message: string;
|
|
106
|
+
} | {
|
|
107
|
+
requiresTwoFactor: true;
|
|
108
|
+
userId: string;
|
|
109
|
+
message: string;
|
|
110
|
+
}>;
|
|
111
|
+
deleteAccount(user: SafeUser, response: Response): Promise<{
|
|
112
|
+
message: string;
|
|
113
|
+
}>;
|
|
35
114
|
private setRefreshTokenCookie;
|
|
36
115
|
}
|
|
@@ -22,9 +22,25 @@ const password_reset_dto_1 = require("./dto/password-reset.dto");
|
|
|
22
22
|
const jwt_auth_guard_1 = require("./guards/jwt-auth.guard");
|
|
23
23
|
const public_decorator_1 = require("../common/decorators/public.decorator");
|
|
24
24
|
const current_user_decorator_1 = require("../common/decorators/current-user.decorator");
|
|
25
|
+
const two_factor_service_1 = require("../two-factor/two-factor.service");
|
|
26
|
+
const verify_two_factor_setup_dto_1 = require("../two-factor/dto/verify-two-factor-setup.dto");
|
|
27
|
+
const account_service_1 = require("../account/account.service");
|
|
28
|
+
const deactivate_account_dto_1 = require("../account/dto/deactivate-account.dto");
|
|
29
|
+
const social_auth_service_1 = require("../social-auth/social-auth.service");
|
|
30
|
+
const dto_1 = require("../social-auth/dto");
|
|
31
|
+
const push_token_service_1 = require("../push-tokens/push-token.service");
|
|
32
|
+
const register_push_token_dto_1 = require("../push-tokens/dto/register-push-token.dto");
|
|
33
|
+
const device_service_1 = require("../devices/device.service");
|
|
34
|
+
const common_2 = require("@nestjs/common");
|
|
35
|
+
const exceptions_1 = require("../common/exceptions");
|
|
25
36
|
let AuthController = class AuthController {
|
|
26
|
-
constructor(authService) {
|
|
37
|
+
constructor(authService, twoFactorService, accountService, socialAuthService, pushTokenService, deviceService) {
|
|
27
38
|
this.authService = authService;
|
|
39
|
+
this.twoFactorService = twoFactorService;
|
|
40
|
+
this.accountService = accountService;
|
|
41
|
+
this.socialAuthService = socialAuthService;
|
|
42
|
+
this.pushTokenService = pushTokenService;
|
|
43
|
+
this.deviceService = deviceService;
|
|
28
44
|
}
|
|
29
45
|
async register(registerDto, response) {
|
|
30
46
|
const result = await this.authService.register(registerDto.email, registerDto.password, registerDto.fullName, registerDto.tenantId);
|
|
@@ -34,8 +50,18 @@ let AuthController = class AuthController {
|
|
|
34
50
|
accessToken: result.accessToken,
|
|
35
51
|
};
|
|
36
52
|
}
|
|
37
|
-
async login(loginDto, response) {
|
|
38
|
-
const
|
|
53
|
+
async login(loginDto, request, response) {
|
|
54
|
+
const deviceInfo = {
|
|
55
|
+
userAgent: request.headers['user-agent'],
|
|
56
|
+
ip: request.ip || request.socket.remoteAddress,
|
|
57
|
+
};
|
|
58
|
+
const result = await this.authService.login(loginDto.email, loginDto.password, deviceInfo);
|
|
59
|
+
if ('requiresTwoFactor' in result) {
|
|
60
|
+
return {
|
|
61
|
+
requiresTwoFactor: true,
|
|
62
|
+
userId: result.userId,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
39
65
|
this.setRefreshTokenCookie(response, result.refreshToken);
|
|
40
66
|
return {
|
|
41
67
|
user: result.user,
|
|
@@ -78,6 +104,127 @@ let AuthController = class AuthController {
|
|
|
78
104
|
await this.authService.verifyEmail(dto.token);
|
|
79
105
|
return { message: 'Email verified successfully' };
|
|
80
106
|
}
|
|
107
|
+
async verifyTwoFactorLogin(dto, request, response) {
|
|
108
|
+
const deviceInfo = {
|
|
109
|
+
userAgent: request.headers['user-agent'],
|
|
110
|
+
ip: request.ip || request.socket.remoteAddress,
|
|
111
|
+
};
|
|
112
|
+
const result = await this.authService.verifyTwoFactorLogin(dto.userId, dto.code, deviceInfo);
|
|
113
|
+
this.setRefreshTokenCookie(response, result.refreshToken);
|
|
114
|
+
return {
|
|
115
|
+
user: result.user,
|
|
116
|
+
accessToken: result.accessToken,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
async enableTwoFactor(user) {
|
|
120
|
+
if (!this.twoFactorService) {
|
|
121
|
+
throw new exceptions_1.FeatureDisabledException('Two-factor authentication');
|
|
122
|
+
}
|
|
123
|
+
const result = await this.twoFactorService.generateTotpSecret(user.id);
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
async verifyTwoFactorSetup(user, dto) {
|
|
127
|
+
if (!this.twoFactorService) {
|
|
128
|
+
throw new exceptions_1.FeatureDisabledException('Two-factor authentication');
|
|
129
|
+
}
|
|
130
|
+
const isValid = await this.twoFactorService.verifyTotpSetup(user.id, dto.code);
|
|
131
|
+
if (!isValid) {
|
|
132
|
+
throw new Error('Invalid 2FA code');
|
|
133
|
+
}
|
|
134
|
+
const result = await this.twoFactorService.enableTwoFactor(user.id);
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
async disableTwoFactor(user) {
|
|
138
|
+
if (!this.twoFactorService) {
|
|
139
|
+
throw new exceptions_1.FeatureDisabledException('Two-factor authentication');
|
|
140
|
+
}
|
|
141
|
+
await this.twoFactorService.disableTwoFactor(user.id);
|
|
142
|
+
return { message: '2FA disabled successfully' };
|
|
143
|
+
}
|
|
144
|
+
async regenerateBackupCodes(user) {
|
|
145
|
+
if (!this.twoFactorService) {
|
|
146
|
+
throw new exceptions_1.FeatureDisabledException('Two-factor authentication');
|
|
147
|
+
}
|
|
148
|
+
const backupCodes = await this.twoFactorService.regenerateBackupCodes(user.id);
|
|
149
|
+
return { backupCodes };
|
|
150
|
+
}
|
|
151
|
+
async googleCallback(dto, response) {
|
|
152
|
+
throw new Error('Google OAuth not fully implemented - requires OAuth code exchange');
|
|
153
|
+
}
|
|
154
|
+
async facebookCallback(dto, response) {
|
|
155
|
+
throw new Error('Facebook OAuth not fully implemented - requires OAuth code exchange');
|
|
156
|
+
}
|
|
157
|
+
async registerPushToken(user, dto) {
|
|
158
|
+
if (!this.pushTokenService) {
|
|
159
|
+
throw new exceptions_1.FeatureDisabledException('Push notifications');
|
|
160
|
+
}
|
|
161
|
+
if (!dto.deviceId) {
|
|
162
|
+
throw new Error('Device ID is required');
|
|
163
|
+
}
|
|
164
|
+
const pushToken = await this.pushTokenService.registerPushToken({
|
|
165
|
+
userId: user.id,
|
|
166
|
+
token: dto.token,
|
|
167
|
+
tokenType: dto.tokenType,
|
|
168
|
+
deviceId: dto.deviceId,
|
|
169
|
+
});
|
|
170
|
+
return pushToken;
|
|
171
|
+
}
|
|
172
|
+
async revokePushToken(user, tokenId) {
|
|
173
|
+
if (!this.pushTokenService) {
|
|
174
|
+
throw new exceptions_1.FeatureDisabledException('Push notifications');
|
|
175
|
+
}
|
|
176
|
+
await this.pushTokenService.revokePushToken(tokenId);
|
|
177
|
+
return { message: 'Push token revoked successfully' };
|
|
178
|
+
}
|
|
179
|
+
async getDevices(user, request) {
|
|
180
|
+
if (!this.deviceService) {
|
|
181
|
+
throw new exceptions_1.FeatureDisabledException('Device management');
|
|
182
|
+
}
|
|
183
|
+
const devices = await this.deviceService.getUserDevices(user.id);
|
|
184
|
+
return devices;
|
|
185
|
+
}
|
|
186
|
+
async revokeDevice(user, deviceId) {
|
|
187
|
+
if (!this.deviceService) {
|
|
188
|
+
throw new exceptions_1.FeatureDisabledException('Device management');
|
|
189
|
+
}
|
|
190
|
+
await this.deviceService.revokeDevice(user.id, deviceId);
|
|
191
|
+
return { message: 'Device revoked successfully' };
|
|
192
|
+
}
|
|
193
|
+
async deactivateAccount(user, dto, response) {
|
|
194
|
+
if (!this.accountService) {
|
|
195
|
+
throw new exceptions_1.FeatureDisabledException('Account management');
|
|
196
|
+
}
|
|
197
|
+
await this.accountService.deactivateAccount(user.id, dto.reason);
|
|
198
|
+
response.clearCookie('refreshToken', {
|
|
199
|
+
httpOnly: true,
|
|
200
|
+
secure: process.env.NODE_ENV === 'production',
|
|
201
|
+
sameSite: 'strict',
|
|
202
|
+
});
|
|
203
|
+
return { message: 'Account deactivated successfully' };
|
|
204
|
+
}
|
|
205
|
+
async reactivateAccount(dto) {
|
|
206
|
+
if (!this.accountService) {
|
|
207
|
+
throw new exceptions_1.FeatureDisabledException('Account management');
|
|
208
|
+
}
|
|
209
|
+
await this.accountService.reactivateAccountByEmail(dto.email);
|
|
210
|
+
const result = await this.authService.login(dto.email, dto.password);
|
|
211
|
+
return {
|
|
212
|
+
message: 'Account reactivated successfully',
|
|
213
|
+
...result,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
async deleteAccount(user, response) {
|
|
217
|
+
if (!this.accountService) {
|
|
218
|
+
throw new exceptions_1.FeatureDisabledException('Account management');
|
|
219
|
+
}
|
|
220
|
+
await this.accountService.deleteAccount(user.id);
|
|
221
|
+
response.clearCookie('refreshToken', {
|
|
222
|
+
httpOnly: true,
|
|
223
|
+
secure: process.env.NODE_ENV === 'production',
|
|
224
|
+
sameSite: 'strict',
|
|
225
|
+
});
|
|
226
|
+
return { message: 'Account deleted successfully' };
|
|
227
|
+
}
|
|
81
228
|
setRefreshTokenCookie(response, refreshToken) {
|
|
82
229
|
response.cookie('refreshToken', refreshToken, {
|
|
83
230
|
httpOnly: true,
|
|
@@ -105,9 +252,10 @@ __decorate([
|
|
|
105
252
|
(0, common_1.Post)('login'),
|
|
106
253
|
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
107
254
|
__param(0, (0, common_1.Body)()),
|
|
108
|
-
__param(1, (0, common_1.
|
|
255
|
+
__param(1, (0, common_1.Req)()),
|
|
256
|
+
__param(2, (0, common_1.Res)({ passthrough: true })),
|
|
109
257
|
__metadata("design:type", Function),
|
|
110
|
-
__metadata("design:paramtypes", [login_dto_1.LoginDto, Object]),
|
|
258
|
+
__metadata("design:paramtypes", [login_dto_1.LoginDto, Object, Object]),
|
|
111
259
|
__metadata("design:returntype", Promise)
|
|
112
260
|
], AuthController.prototype, "login", null);
|
|
113
261
|
__decorate([
|
|
@@ -166,8 +314,158 @@ __decorate([
|
|
|
166
314
|
__metadata("design:paramtypes", [password_reset_dto_1.VerifyEmailDto]),
|
|
167
315
|
__metadata("design:returntype", Promise)
|
|
168
316
|
], AuthController.prototype, "verifyEmail", null);
|
|
317
|
+
__decorate([
|
|
318
|
+
(0, public_decorator_1.Public)(),
|
|
319
|
+
(0, throttler_1.Throttle)({ default: { limit: 5, ttl: 60000 } }),
|
|
320
|
+
(0, common_1.Post)('2fa/verify-login'),
|
|
321
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
322
|
+
__param(0, (0, common_1.Body)()),
|
|
323
|
+
__param(1, (0, common_1.Req)()),
|
|
324
|
+
__param(2, (0, common_1.Res)({ passthrough: true })),
|
|
325
|
+
__metadata("design:type", Function),
|
|
326
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
327
|
+
__metadata("design:returntype", Promise)
|
|
328
|
+
], AuthController.prototype, "verifyTwoFactorLogin", null);
|
|
329
|
+
__decorate([
|
|
330
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
331
|
+
(0, common_1.Post)('2fa/enable'),
|
|
332
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
333
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
334
|
+
__metadata("design:type", Function),
|
|
335
|
+
__metadata("design:paramtypes", [Object]),
|
|
336
|
+
__metadata("design:returntype", Promise)
|
|
337
|
+
], AuthController.prototype, "enableTwoFactor", null);
|
|
338
|
+
__decorate([
|
|
339
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
340
|
+
(0, common_1.Post)('2fa/verify'),
|
|
341
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
342
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
343
|
+
__param(1, (0, common_1.Body)()),
|
|
344
|
+
__metadata("design:type", Function),
|
|
345
|
+
__metadata("design:paramtypes", [Object, verify_two_factor_setup_dto_1.VerifyTwoFactorSetupDto]),
|
|
346
|
+
__metadata("design:returntype", Promise)
|
|
347
|
+
], AuthController.prototype, "verifyTwoFactorSetup", null);
|
|
348
|
+
__decorate([
|
|
349
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
350
|
+
(0, common_1.Post)('2fa/disable'),
|
|
351
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
352
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
353
|
+
__metadata("design:type", Function),
|
|
354
|
+
__metadata("design:paramtypes", [Object]),
|
|
355
|
+
__metadata("design:returntype", Promise)
|
|
356
|
+
], AuthController.prototype, "disableTwoFactor", null);
|
|
357
|
+
__decorate([
|
|
358
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
359
|
+
(0, common_1.Post)('2fa/backup-codes/regenerate'),
|
|
360
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
361
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
362
|
+
__metadata("design:type", Function),
|
|
363
|
+
__metadata("design:paramtypes", [Object]),
|
|
364
|
+
__metadata("design:returntype", Promise)
|
|
365
|
+
], AuthController.prototype, "regenerateBackupCodes", null);
|
|
366
|
+
__decorate([
|
|
367
|
+
(0, public_decorator_1.Public)(),
|
|
368
|
+
(0, throttler_1.Throttle)({ default: { limit: 5, ttl: 60000 } }),
|
|
369
|
+
(0, common_1.Post)('social/google'),
|
|
370
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
371
|
+
__param(0, (0, common_1.Body)()),
|
|
372
|
+
__param(1, (0, common_1.Res)({ passthrough: true })),
|
|
373
|
+
__metadata("design:type", Function),
|
|
374
|
+
__metadata("design:paramtypes", [dto_1.GoogleCallbackDto, Object]),
|
|
375
|
+
__metadata("design:returntype", Promise)
|
|
376
|
+
], AuthController.prototype, "googleCallback", null);
|
|
377
|
+
__decorate([
|
|
378
|
+
(0, public_decorator_1.Public)(),
|
|
379
|
+
(0, throttler_1.Throttle)({ default: { limit: 5, ttl: 60000 } }),
|
|
380
|
+
(0, common_1.Post)('social/facebook'),
|
|
381
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
382
|
+
__param(0, (0, common_1.Body)()),
|
|
383
|
+
__param(1, (0, common_1.Res)({ passthrough: true })),
|
|
384
|
+
__metadata("design:type", Function),
|
|
385
|
+
__metadata("design:paramtypes", [dto_1.FacebookCallbackDto, Object]),
|
|
386
|
+
__metadata("design:returntype", Promise)
|
|
387
|
+
], AuthController.prototype, "facebookCallback", null);
|
|
388
|
+
__decorate([
|
|
389
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
390
|
+
(0, common_1.Post)('push-tokens'),
|
|
391
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
392
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
393
|
+
__param(1, (0, common_1.Body)()),
|
|
394
|
+
__metadata("design:type", Function),
|
|
395
|
+
__metadata("design:paramtypes", [Object, register_push_token_dto_1.RegisterPushTokenDto]),
|
|
396
|
+
__metadata("design:returntype", Promise)
|
|
397
|
+
], AuthController.prototype, "registerPushToken", null);
|
|
398
|
+
__decorate([
|
|
399
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
400
|
+
(0, common_1.Delete)('push-tokens/:tokenId'),
|
|
401
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
402
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
403
|
+
__param(1, (0, common_1.Param)('tokenId')),
|
|
404
|
+
__metadata("design:type", Function),
|
|
405
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
406
|
+
__metadata("design:returntype", Promise)
|
|
407
|
+
], AuthController.prototype, "revokePushToken", null);
|
|
408
|
+
__decorate([
|
|
409
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
410
|
+
(0, common_1.Get)('devices'),
|
|
411
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
412
|
+
__param(1, (0, common_1.Req)()),
|
|
413
|
+
__metadata("design:type", Function),
|
|
414
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
415
|
+
__metadata("design:returntype", Promise)
|
|
416
|
+
], AuthController.prototype, "getDevices", null);
|
|
417
|
+
__decorate([
|
|
418
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
419
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
420
|
+
(0, common_1.Post)('devices/:deviceId/revoke'),
|
|
421
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
422
|
+
__param(1, (0, common_1.Param)('deviceId')),
|
|
423
|
+
__metadata("design:type", Function),
|
|
424
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
425
|
+
__metadata("design:returntype", Promise)
|
|
426
|
+
], AuthController.prototype, "revokeDevice", null);
|
|
427
|
+
__decorate([
|
|
428
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
429
|
+
(0, common_1.Post)('account/deactivate'),
|
|
430
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
431
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
432
|
+
__param(1, (0, common_1.Body)()),
|
|
433
|
+
__param(2, (0, common_1.Res)({ passthrough: true })),
|
|
434
|
+
__metadata("design:type", Function),
|
|
435
|
+
__metadata("design:paramtypes", [Object, deactivate_account_dto_1.DeactivateAccountDto, Object]),
|
|
436
|
+
__metadata("design:returntype", Promise)
|
|
437
|
+
], AuthController.prototype, "deactivateAccount", null);
|
|
438
|
+
__decorate([
|
|
439
|
+
(0, public_decorator_1.Public)(),
|
|
440
|
+
(0, common_1.Post)('account/reactivate'),
|
|
441
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
442
|
+
__param(0, (0, common_1.Body)()),
|
|
443
|
+
__metadata("design:type", Function),
|
|
444
|
+
__metadata("design:paramtypes", [Object]),
|
|
445
|
+
__metadata("design:returntype", Promise)
|
|
446
|
+
], AuthController.prototype, "reactivateAccount", null);
|
|
447
|
+
__decorate([
|
|
448
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
449
|
+
(0, common_1.Delete)('account'),
|
|
450
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
451
|
+
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
452
|
+
__param(1, (0, common_1.Res)({ passthrough: true })),
|
|
453
|
+
__metadata("design:type", Function),
|
|
454
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
455
|
+
__metadata("design:returntype", Promise)
|
|
456
|
+
], AuthController.prototype, "deleteAccount", null);
|
|
169
457
|
exports.AuthController = AuthController = __decorate([
|
|
170
458
|
(0, common_1.Controller)('auth'),
|
|
171
|
-
|
|
459
|
+
__param(1, (0, common_2.Optional)()),
|
|
460
|
+
__param(2, (0, common_2.Optional)()),
|
|
461
|
+
__param(3, (0, common_2.Optional)()),
|
|
462
|
+
__param(4, (0, common_2.Optional)()),
|
|
463
|
+
__param(5, (0, common_2.Optional)()),
|
|
464
|
+
__metadata("design:paramtypes", [auth_service_1.AuthService,
|
|
465
|
+
two_factor_service_1.TwoFactorService,
|
|
466
|
+
account_service_1.AccountService,
|
|
467
|
+
social_auth_service_1.SocialAuthService,
|
|
468
|
+
push_token_service_1.PushTokenService,
|
|
469
|
+
device_service_1.DeviceService])
|
|
172
470
|
], AuthController);
|
|
173
471
|
//# sourceMappingURL=auth.controller.js.map
|