@flusys/nestjs-auth 4.1.0 → 5.0.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/README.md +151 -719
- package/cjs/config/message-keys.js +6 -61
- package/cjs/controllers/authentication.controller.js +113 -87
- package/cjs/controllers/company-selection.controller.js +24 -4
- package/cjs/controllers/email-verification.controller.js +12 -13
- package/cjs/docs/auth-swagger.config.js +143 -106
- package/cjs/dtos/authentication.dto.js +0 -15
- package/cjs/entities/user-company-permission.entity.js +0 -8
- package/cjs/entities/user-token.entity.js +0 -9
- package/cjs/interceptors/set-token.interceptor.js +15 -7
- package/cjs/services/auth-config.service.js +0 -4
- package/cjs/services/auth-email.service.js +8 -31
- package/cjs/services/authentication.service.js +99 -15
- package/cjs/services/user-permission.service.js +6 -8
- package/cjs/services/user.service.js +12 -9
- package/cjs/strategies/jwt.strategy.js +10 -3
- package/config/message-keys.d.ts +5 -153
- package/controllers/authentication.controller.d.ts +6 -7
- package/controllers/company-selection.controller.d.ts +3 -2
- package/controllers/email-verification.controller.d.ts +6 -2
- package/dtos/authentication.dto.d.ts +0 -2
- package/entities/user-company-permission.entity.d.ts +0 -1
- package/entities/user-token.entity.d.ts +0 -1
- package/fesm/config/message-keys.js +6 -53
- package/fesm/controllers/authentication.controller.js +115 -90
- package/fesm/controllers/company-selection.controller.js +25 -5
- package/fesm/controllers/email-verification.controller.js +13 -14
- package/fesm/docs/auth-swagger.config.js +146 -113
- package/fesm/dtos/authentication.dto.js +0 -15
- package/fesm/entities/user-company-permission.entity.js +0 -8
- package/fesm/entities/user-token.entity.js +0 -9
- package/fesm/interceptors/set-token.interceptor.js +15 -7
- package/fesm/services/auth-config.service.js +0 -4
- package/fesm/services/auth-email.service.js +8 -32
- package/fesm/services/authentication.service.js +100 -17
- package/fesm/services/user-permission.service.js +6 -8
- package/fesm/services/user.service.js +12 -10
- package/fesm/strategies/jwt.strategy.js +10 -3
- package/interfaces/auth-module-options.interface.d.ts +0 -1
- package/package.json +3 -3
- package/services/auth-config.service.d.ts +0 -1
- package/services/auth-email.service.d.ts +0 -4
- package/services/authentication.service.d.ts +1 -1
- package/services/user-permission.service.d.ts +1 -1
- package/services/user.service.d.ts +5 -5
|
@@ -25,18 +25,16 @@ function _ts_param(paramIndex, decorator) {
|
|
|
25
25
|
decorator(target, key, paramIndex);
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
import { LogAction } from '@flusys/nestjs-shared';
|
|
28
29
|
import { HybridCache } from '@flusys/nestjs-shared/classes';
|
|
29
30
|
import { SYSTEM_MESSAGES } from '@flusys/nestjs-shared/constants';
|
|
30
|
-
import { LogAction } from '@flusys/nestjs-shared';
|
|
31
|
-
import { AUTH_MESSAGES, EMAIL_VERIFICATION_MESSAGES, USER_MESSAGES } from '../config';
|
|
32
|
-
import { INotificationAdapter, NOTIFICATION_ADAPTER } from '@flusys/nestjs-shared/interfaces';
|
|
33
31
|
import { NotificationType } from '@flusys/nestjs-shared/enums';
|
|
32
|
+
import { INotificationAdapter, NOTIFICATION_ADAPTER } from '@flusys/nestjs-shared/interfaces';
|
|
34
33
|
import { generateUniqueSlug } from '@flusys/nestjs-shared/utils';
|
|
35
|
-
import { BadRequestException, Inject, Injectable, InternalServerErrorException, NotFoundException, Optional, Scope, UnauthorizedException } from '@nestjs/common';
|
|
34
|
+
import { BadRequestException, ForbiddenException, Inject, Injectable, InternalServerErrorException, NotFoundException, Optional, Scope, UnauthorizedException } from '@nestjs/common';
|
|
36
35
|
import { JwtService } from '@nestjs/jwt';
|
|
37
36
|
import * as bcrypt from 'bcrypt';
|
|
38
|
-
import { BCRYPT_SALT_ROUNDS, TOKEN_REVOKED_PREFIX, USER_ENRICHER } from '../config';
|
|
39
|
-
import { IUserEnricher } from '../interfaces/user-enricher.interface';
|
|
37
|
+
import { AUTH_MESSAGES, BCRYPT_SALT_ROUNDS, EMAIL_VERIFICATION_MESSAGES, TOKEN_REVOKED_PREFIX, USER_ENRICHER, USER_MESSAGES } from '../config';
|
|
40
38
|
import { RegistrationDto } from '../dtos/authentication.dto';
|
|
41
39
|
import { CompanyBranch } from '../entities/company-branch.entity';
|
|
42
40
|
import { Company } from '../entities/company.entity';
|
|
@@ -44,6 +42,7 @@ import { PendingRegistration } from '../entities/pending-registration.entity';
|
|
|
44
42
|
import { UserCompanyPermission } from '../entities/user-company-permission.entity';
|
|
45
43
|
import { User } from '../entities/user.entity';
|
|
46
44
|
import { PermissionType } from '../enums';
|
|
45
|
+
import { IUserEnricher } from '../interfaces/user-enricher.interface';
|
|
47
46
|
import { AuthConfigService } from './auth-config.service';
|
|
48
47
|
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
49
48
|
import { AuthEmailService } from './auth-email.service';
|
|
@@ -61,7 +60,10 @@ export class AuthenticationService {
|
|
|
61
60
|
if (!this.dataSourceProvider) {
|
|
62
61
|
throw new InternalServerErrorException({
|
|
63
62
|
message: 'User repository not available',
|
|
64
|
-
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE
|
|
63
|
+
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
|
|
64
|
+
messageVariables: {
|
|
65
|
+
entity: 'User'
|
|
66
|
+
}
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
69
|
return this.dataSourceProvider.getRepository(User);
|
|
@@ -89,7 +91,7 @@ export class AuthenticationService {
|
|
|
89
91
|
}
|
|
90
92
|
const user = await this.validateUser(email, password);
|
|
91
93
|
if (!user.isActive) {
|
|
92
|
-
throw new
|
|
94
|
+
throw new ForbiddenException({
|
|
93
95
|
message: 'User account is deactivated',
|
|
94
96
|
messageKey: AUTH_MESSAGES.LOGIN_ACCOUNT_DEACTIVATED
|
|
95
97
|
});
|
|
@@ -202,7 +204,10 @@ export class AuthenticationService {
|
|
|
202
204
|
if (!permissionRepository || !companyRepository) {
|
|
203
205
|
throw new BadRequestException({
|
|
204
206
|
message: 'Company feature repositories not available',
|
|
205
|
-
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE
|
|
207
|
+
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
|
|
208
|
+
messageVariables: {
|
|
209
|
+
entity: 'Company feature'
|
|
210
|
+
}
|
|
206
211
|
});
|
|
207
212
|
}
|
|
208
213
|
if (dto.companySlug) {
|
|
@@ -335,7 +340,10 @@ export class AuthenticationService {
|
|
|
335
340
|
if (!companyRepository || !branchRepository || !permissionRepository) {
|
|
336
341
|
if (throwOnUnavailable) throw new BadRequestException({
|
|
337
342
|
message: 'Company feature repositories not available',
|
|
338
|
-
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE
|
|
343
|
+
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
|
|
344
|
+
messageVariables: {
|
|
345
|
+
entity: 'Company feature'
|
|
346
|
+
}
|
|
339
347
|
});
|
|
340
348
|
return this.generateRegistrationResponse(user);
|
|
341
349
|
}
|
|
@@ -470,7 +478,10 @@ export class AuthenticationService {
|
|
|
470
478
|
if (!permissionRepository || !companyRepository || !branchRepository) {
|
|
471
479
|
throw new BadRequestException({
|
|
472
480
|
message: 'Repositories not available',
|
|
473
|
-
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE
|
|
481
|
+
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
|
|
482
|
+
messageVariables: {
|
|
483
|
+
entity: 'Some'
|
|
484
|
+
}
|
|
474
485
|
});
|
|
475
486
|
}
|
|
476
487
|
const hasCompanyAccess = await permissionRepository.findOne({
|
|
@@ -481,7 +492,7 @@ export class AuthenticationService {
|
|
|
481
492
|
}
|
|
482
493
|
});
|
|
483
494
|
if (!hasCompanyAccess) {
|
|
484
|
-
throw new
|
|
495
|
+
throw new ForbiddenException({
|
|
485
496
|
message: 'No access to this company',
|
|
486
497
|
messageKey: AUTH_MESSAGES.COMPANY_NO_ACCESS
|
|
487
498
|
});
|
|
@@ -493,7 +504,7 @@ export class AuthenticationService {
|
|
|
493
504
|
}
|
|
494
505
|
});
|
|
495
506
|
if (!company) {
|
|
496
|
-
throw new
|
|
507
|
+
throw new NotFoundException({
|
|
497
508
|
message: 'Company not found or inactive',
|
|
498
509
|
messageKey: AUTH_MESSAGES.COMPANY_NOT_FOUND
|
|
499
510
|
});
|
|
@@ -506,7 +517,7 @@ export class AuthenticationService {
|
|
|
506
517
|
}
|
|
507
518
|
});
|
|
508
519
|
if (!hasBranchAccess) {
|
|
509
|
-
throw new
|
|
520
|
+
throw new ForbiddenException({
|
|
510
521
|
message: 'No access to this branch',
|
|
511
522
|
messageKey: AUTH_MESSAGES.BRANCH_NO_ACCESS
|
|
512
523
|
});
|
|
@@ -519,7 +530,7 @@ export class AuthenticationService {
|
|
|
519
530
|
}
|
|
520
531
|
});
|
|
521
532
|
if (!branch) {
|
|
522
|
-
throw new
|
|
533
|
+
throw new NotFoundException({
|
|
523
534
|
message: 'Branch not found or inactive',
|
|
524
535
|
messageKey: AUTH_MESSAGES.BRANCH_NOT_FOUND
|
|
525
536
|
});
|
|
@@ -549,6 +560,72 @@ export class AuthenticationService {
|
|
|
549
560
|
messageKey: AUTH_MESSAGES.TOKEN_INVALID
|
|
550
561
|
});
|
|
551
562
|
}
|
|
563
|
+
if (payload.companyId) {
|
|
564
|
+
const companyRepository = await this.getCompanyRepository();
|
|
565
|
+
const permissionRepository = await this.getPermissionRepository();
|
|
566
|
+
if (companyRepository) {
|
|
567
|
+
const company = await companyRepository.findOne({
|
|
568
|
+
where: {
|
|
569
|
+
id: payload.companyId,
|
|
570
|
+
isActive: true
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
if (!company) {
|
|
574
|
+
throw new UnauthorizedException({
|
|
575
|
+
message: 'Company not found or inactive',
|
|
576
|
+
messageKey: AUTH_MESSAGES.COMPANY_NOT_FOUND
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (permissionRepository) {
|
|
581
|
+
const hasCompanyAccess = await permissionRepository.findOne({
|
|
582
|
+
where: {
|
|
583
|
+
userId: user.id,
|
|
584
|
+
permissionType: PermissionType.COMPANY,
|
|
585
|
+
targetId: payload.companyId
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
if (!hasCompanyAccess) {
|
|
589
|
+
throw new UnauthorizedException({
|
|
590
|
+
message: 'No access to this company',
|
|
591
|
+
messageKey: AUTH_MESSAGES.COMPANY_NO_ACCESS
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (payload.branchId) {
|
|
596
|
+
const branchRepository = await this.getBranchRepository();
|
|
597
|
+
if (branchRepository) {
|
|
598
|
+
const branch = await branchRepository.findOne({
|
|
599
|
+
where: {
|
|
600
|
+
id: payload.branchId,
|
|
601
|
+
companyId: payload.companyId,
|
|
602
|
+
isActive: true
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
if (!branch) {
|
|
606
|
+
throw new UnauthorizedException({
|
|
607
|
+
message: 'Branch not found or inactive',
|
|
608
|
+
messageKey: AUTH_MESSAGES.BRANCH_NOT_FOUND
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (permissionRepository) {
|
|
613
|
+
const hasBranchAccess = await permissionRepository.findOne({
|
|
614
|
+
where: {
|
|
615
|
+
userId: user.id,
|
|
616
|
+
permissionType: PermissionType.BRANCH,
|
|
617
|
+
targetId: payload.branchId
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
if (!hasBranchAccess) {
|
|
621
|
+
throw new UnauthorizedException({
|
|
622
|
+
message: 'No access to this branch',
|
|
623
|
+
messageKey: AUTH_MESSAGES.BRANCH_NO_ACCESS
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
552
629
|
return this.generateTokens({
|
|
553
630
|
id: user.id,
|
|
554
631
|
email: user.email,
|
|
@@ -637,7 +714,10 @@ export class AuthenticationService {
|
|
|
637
714
|
if (!permissionRepository || !companyRepository) {
|
|
638
715
|
throw new BadRequestException({
|
|
639
716
|
message: 'Repositories not available',
|
|
640
|
-
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE
|
|
717
|
+
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
|
|
718
|
+
messageVariables: {
|
|
719
|
+
entity: 'Some'
|
|
720
|
+
}
|
|
641
721
|
});
|
|
642
722
|
}
|
|
643
723
|
const permissions = await permissionRepository.find({
|
|
@@ -661,7 +741,10 @@ export class AuthenticationService {
|
|
|
661
741
|
if (!permissionRepository || !branchRepository) {
|
|
662
742
|
throw new BadRequestException({
|
|
663
743
|
message: 'Repositories not available',
|
|
664
|
-
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE
|
|
744
|
+
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
|
|
745
|
+
messageVariables: {
|
|
746
|
+
entity: 'Some'
|
|
747
|
+
}
|
|
665
748
|
});
|
|
666
749
|
}
|
|
667
750
|
const companyPermission = await permissionRepository.findOne({
|
|
@@ -53,7 +53,7 @@ export class UserPermissionService {
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
/** Assign permission to user */ async assignPermission(userId, targetId, type
|
|
56
|
+
/** Assign permission to user */ async assignPermission(userId, targetId, type) {
|
|
57
57
|
const repository = await this.getRepository();
|
|
58
58
|
const typeName = type === PermissionType.COMPANY ? 'company' : 'branch';
|
|
59
59
|
const existing = await repository.findOne({
|
|
@@ -67,7 +67,7 @@ export class UserPermissionService {
|
|
|
67
67
|
throw new ConflictException({
|
|
68
68
|
message: `User already assigned to this ${typeName}`,
|
|
69
69
|
messageKey: USER_PERMISSION_MESSAGES.ALREADY_ASSIGNED,
|
|
70
|
-
|
|
70
|
+
messageVariables: {
|
|
71
71
|
type: typeName
|
|
72
72
|
}
|
|
73
73
|
});
|
|
@@ -76,8 +76,7 @@ export class UserPermissionService {
|
|
|
76
76
|
await repository.save(repository.create({
|
|
77
77
|
userId,
|
|
78
78
|
permissionType: type,
|
|
79
|
-
targetId
|
|
80
|
-
metadata
|
|
79
|
+
targetId
|
|
81
80
|
}));
|
|
82
81
|
} catch (error) {
|
|
83
82
|
const err = error;
|
|
@@ -85,7 +84,7 @@ export class UserPermissionService {
|
|
|
85
84
|
throw new ConflictException({
|
|
86
85
|
message: `User already assigned to this ${typeName}. Please refresh and try again.`,
|
|
87
86
|
messageKey: USER_PERMISSION_MESSAGES.ALREADY_ASSIGNED,
|
|
88
|
-
|
|
87
|
+
messageVariables: {
|
|
89
88
|
type: typeName
|
|
90
89
|
}
|
|
91
90
|
});
|
|
@@ -107,7 +106,7 @@ export class UserPermissionService {
|
|
|
107
106
|
throw new NotFoundException({
|
|
108
107
|
message: `${typeName.charAt(0).toUpperCase() + typeName.slice(1)} permission not found`,
|
|
109
108
|
messageKey: USER_PERMISSION_MESSAGES.PERMISSION_NOT_FOUND,
|
|
110
|
-
|
|
109
|
+
messageVariables: {
|
|
111
110
|
type: typeName.charAt(0).toUpperCase() + typeName.slice(1)
|
|
112
111
|
}
|
|
113
112
|
});
|
|
@@ -147,8 +146,7 @@ _ts_decorate([
|
|
|
147
146
|
_ts_metadata("design:paramtypes", [
|
|
148
147
|
String,
|
|
149
148
|
String,
|
|
150
|
-
typeof PermissionType === "undefined" ? Object : PermissionType
|
|
151
|
-
typeof Record === "undefined" ? Object : Record
|
|
149
|
+
typeof PermissionType === "undefined" ? Object : PermissionType
|
|
152
150
|
]),
|
|
153
151
|
_ts_metadata("design:returntype", Promise)
|
|
154
152
|
], UserPermissionService.prototype, "assignPermission", null);
|
|
@@ -25,22 +25,21 @@ function _ts_param(paramIndex, decorator) {
|
|
|
25
25
|
decorator(target, key, paramIndex);
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
import { RequestScopedApiService, HybridCache } from '@flusys/nestjs-shared/classes';
|
|
29
28
|
import { LogAction } from '@flusys/nestjs-shared';
|
|
29
|
+
import { HybridCache, RequestScopedApiService } from '@flusys/nestjs-shared/classes';
|
|
30
|
+
import { SYSTEM_MESSAGES } from '@flusys/nestjs-shared/constants';
|
|
30
31
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
31
32
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
32
33
|
import { BadRequestException, ForbiddenException, Inject, Injectable, NotFoundException, Optional, Scope } from '@nestjs/common';
|
|
33
|
-
import { SYSTEM_MESSAGES } from '@flusys/nestjs-shared/constants';
|
|
34
|
-
import { AUTH_MESSAGES, USER_MESSAGES, USER_PERMISSION_MESSAGES } from '../config';
|
|
35
34
|
import * as bcrypt from 'bcrypt';
|
|
36
|
-
import {
|
|
37
|
-
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
38
|
-
import { BCRYPT_SALT_ROUNDS, USER_ENRICHER } from '../config';
|
|
35
|
+
import { AUTH_MESSAGES, BCRYPT_SALT_ROUNDS, USER_ENRICHER, USER_MESSAGES, USER_PERMISSION_MESSAGES } from '../config';
|
|
39
36
|
import { CreateUserDto } from '../dtos/user.dto';
|
|
40
|
-
import { PermissionType } from '../enums';
|
|
41
|
-
import { IUserEnricher } from '../interfaces/user-enricher.interface';
|
|
42
37
|
import { UserCompanyPermission } from '../entities/user-company-permission.entity';
|
|
43
38
|
import { User } from '../entities/user.entity';
|
|
39
|
+
import { PermissionType } from '../enums';
|
|
40
|
+
import { IUserEnricher } from '../interfaces/user-enricher.interface';
|
|
41
|
+
import { AuthConfigService } from './auth-config.service';
|
|
42
|
+
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
44
43
|
export class UserService extends RequestScopedApiService {
|
|
45
44
|
resolveEntity() {
|
|
46
45
|
return User;
|
|
@@ -63,7 +62,7 @@ export class UserService extends RequestScopedApiService {
|
|
|
63
62
|
async getUserForProfile(userId, user) {
|
|
64
63
|
if (userId !== user.id) {
|
|
65
64
|
throw new ForbiddenException({
|
|
66
|
-
message:
|
|
65
|
+
message: "Cannot access another user's profile",
|
|
67
66
|
messageKey: AUTH_MESSAGES.PROFILE_ACCESS_DENIED
|
|
68
67
|
});
|
|
69
68
|
}
|
|
@@ -117,7 +116,10 @@ export class UserService extends RequestScopedApiService {
|
|
|
117
116
|
if (!permission) {
|
|
118
117
|
throw new NotFoundException({
|
|
119
118
|
message: 'User company permission not found',
|
|
120
|
-
messageKey: USER_PERMISSION_MESSAGES.PERMISSION_NOT_FOUND
|
|
119
|
+
messageKey: USER_PERMISSION_MESSAGES.PERMISSION_NOT_FOUND,
|
|
120
|
+
messageVariables: {
|
|
121
|
+
type: 'User company'
|
|
122
|
+
}
|
|
121
123
|
});
|
|
122
124
|
}
|
|
123
125
|
permission.isActive = isActive;
|
|
@@ -22,10 +22,10 @@ function _ts_metadata(k, v) {
|
|
|
22
22
|
}
|
|
23
23
|
import { SYSTEM_MESSAGES } from '@flusys/nestjs-shared/constants';
|
|
24
24
|
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|
25
|
-
import { AUTH_MESSAGES, USER_MESSAGES } from '../config';
|
|
26
25
|
import { ModuleRef } from '@nestjs/core';
|
|
27
26
|
import { PassportStrategy } from '@nestjs/passport';
|
|
28
27
|
import { ExtractJwt, Strategy } from 'passport-jwt';
|
|
28
|
+
import { AUTH_MESSAGES, USER_MESSAGES } from '../config';
|
|
29
29
|
import { User } from '../entities/user.entity';
|
|
30
30
|
import { AuthConfigService } from '../services/auth-config.service';
|
|
31
31
|
import { AuthDataSourceProvider } from '../services/auth-datasource.provider';
|
|
@@ -62,12 +62,19 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
|
|
62
62
|
} catch {
|
|
63
63
|
throw new UnauthorizedException({
|
|
64
64
|
message: 'Unable to access user data',
|
|
65
|
-
messageKey: SYSTEM_MESSAGES.SERVICE_NOT_AVAILABLE
|
|
65
|
+
messageKey: SYSTEM_MESSAGES.SERVICE_NOT_AVAILABLE,
|
|
66
|
+
messageVariables: {
|
|
67
|
+
provider: 'DataSourceProvider',
|
|
68
|
+
available: ''
|
|
69
|
+
}
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
72
|
throw new UnauthorizedException({
|
|
69
73
|
message: 'User repository not available',
|
|
70
|
-
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE
|
|
74
|
+
messageKey: SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
|
|
75
|
+
messageVariables: {
|
|
76
|
+
entity: 'User'
|
|
77
|
+
}
|
|
71
78
|
});
|
|
72
79
|
}
|
|
73
80
|
async checkTokenRevocation(payload) {
|
|
@@ -6,7 +6,6 @@ export interface IAuthModuleConfig extends IDataSourceServiceOptions {
|
|
|
6
6
|
refreshTokenSecret?: string;
|
|
7
7
|
refreshTokenExpiration?: string;
|
|
8
8
|
refreshTokenCookieName?: string;
|
|
9
|
-
frontendUrl?: string;
|
|
10
9
|
}
|
|
11
10
|
export interface AuthModuleOptions extends IDynamicModuleConfig {
|
|
12
11
|
bootstrapAppConfig?: IBootstrapAppConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Authentication and authorization infrastructure for NestJS applications",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "fesm/index.js",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"rxjs": "^7.8.0"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@flusys/nestjs-core": "
|
|
97
|
-
"@flusys/nestjs-shared": "
|
|
96
|
+
"@flusys/nestjs-core": "5.0.0",
|
|
97
|
+
"@flusys/nestjs-shared": "5.0.0"
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { HybridCache } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { INotificationAdapter } from '@flusys/nestjs-shared/interfaces';
|
|
3
3
|
import { JwtService } from '@nestjs/jwt';
|
|
4
|
-
import { IUserEnricher } from '../interfaces/user-enricher.interface';
|
|
5
4
|
import { RegistrationDto } from '../dtos/authentication.dto';
|
|
6
5
|
import { CompanyBranch } from '../entities/company-branch.entity';
|
|
7
6
|
import { Company } from '../entities/company.entity';
|
|
8
7
|
import { PendingRegistration } from '../entities/pending-registration.entity';
|
|
9
8
|
import { LoginResponse, LoginResponseRequiresEmailVerification, LoginResponseRequiresSelection, MeResponse, RegistrationResponse } from '../interfaces/authentication.interface';
|
|
9
|
+
import { IUserEnricher } from '../interfaces/user-enricher.interface';
|
|
10
10
|
import { AuthConfigService } from './auth-config.service';
|
|
11
11
|
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
12
12
|
import { AuthEmailService } from './auth-email.service';
|
|
@@ -6,7 +6,7 @@ export declare class UserPermissionService {
|
|
|
6
6
|
constructor(dataSourceProvider: AuthDataSourceProvider);
|
|
7
7
|
private getRepository;
|
|
8
8
|
findUserPermissions(userId: string, type: PermissionType): Promise<UserCompanyPermission[]>;
|
|
9
|
-
assignPermission(userId: string, targetId: string, type: PermissionType
|
|
9
|
+
assignPermission(userId: string, targetId: string, type: PermissionType): Promise<void>;
|
|
10
10
|
revokePermission(userId: string, targetId: string, type: PermissionType): Promise<void>;
|
|
11
11
|
findUserCompanies: (userId: string) => Promise<UserCompanyPermission[]>;
|
|
12
12
|
findUserBranches(userId: string, companyId?: string): Promise<UserCompanyPermission[]>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HybridCache, RequestScopedApiService } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { FilterAndPaginationDto } from '@flusys/nestjs-shared/dtos';
|
|
3
3
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
4
4
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
5
5
|
import { EntityTarget, Repository, SelectQueryBuilder } from 'typeorm';
|
|
6
|
-
import { AuthConfigService } from './auth-config.service';
|
|
7
|
-
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
8
6
|
import { CreateUserDto, UpdateUserDto } from '../dtos/user.dto';
|
|
9
|
-
import { IUser } from '../interfaces/user.interface';
|
|
10
|
-
import { IEnrichedUser, IProfileExtras, IProfileSection, IProfileSectionData, IUserEnricher } from '../interfaces/user-enricher.interface';
|
|
11
7
|
import { User } from '../entities/user.entity';
|
|
8
|
+
import { IEnrichedUser, IProfileExtras, IProfileSection, IProfileSectionData, IUserEnricher } from '../interfaces/user-enricher.interface';
|
|
9
|
+
import { IUser } from '../interfaces/user.interface';
|
|
10
|
+
import { AuthConfigService } from './auth-config.service';
|
|
11
|
+
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
12
12
|
export declare class UserService extends RequestScopedApiService<CreateUserDto, UpdateUserDto, IUser, User, Repository<User>> {
|
|
13
13
|
protected cacheManager: HybridCache;
|
|
14
14
|
protected utilsService: UtilsService;
|