@flusys/nestjs-auth 3.0.0 → 4.0.0-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/cjs/config/index.js +1 -0
  3. package/cjs/config/message-keys.js +150 -0
  4. package/cjs/controllers/authentication.controller.js +9 -4
  5. package/cjs/controllers/branch.controller.js +1 -0
  6. package/cjs/controllers/company-selection.controller.js +3 -0
  7. package/cjs/controllers/company.controller.js +1 -0
  8. package/cjs/controllers/email-verification.controller.js +7 -2
  9. package/cjs/controllers/user-permission.controller.js +9 -1
  10. package/cjs/controllers/user.controller.js +16 -4
  11. package/cjs/dtos/authentication.dto.js +8 -0
  12. package/cjs/dtos/user-permission.dto.js +14 -0
  13. package/cjs/interceptors/set-token.interceptor.js +14 -5
  14. package/cjs/services/auth-config.service.js +9 -8
  15. package/cjs/services/auth-datasource.provider.js +7 -4
  16. package/cjs/services/auth-email.service.js +155 -45
  17. package/cjs/services/authentication.service.js +306 -71
  18. package/cjs/services/branch.service.js +1 -1
  19. package/cjs/services/company-selection-session.service.js +25 -6
  20. package/cjs/services/company.service.js +1 -1
  21. package/cjs/services/user-permission.service.js +52 -4
  22. package/cjs/services/user.service.js +122 -26
  23. package/cjs/strategies/jwt.strategy.js +18 -4
  24. package/config/index.d.ts +1 -0
  25. package/config/message-keys.d.ts +218 -0
  26. package/controllers/company-selection.controller.d.ts +2 -0
  27. package/controllers/user-permission.controller.d.ts +4 -0
  28. package/controllers/user.controller.d.ts +10 -0
  29. package/dtos/authentication.dto.d.ts +1 -0
  30. package/dtos/user-permission.dto.d.ts +2 -0
  31. package/entities/index.d.ts +10 -1
  32. package/fesm/config/index.js +1 -0
  33. package/fesm/config/message-keys.js +118 -0
  34. package/fesm/controllers/authentication.controller.js +9 -3
  35. package/fesm/controllers/branch.controller.js +1 -0
  36. package/fesm/controllers/company-selection.controller.js +3 -0
  37. package/fesm/controllers/company.controller.js +1 -0
  38. package/fesm/controllers/email-verification.controller.js +7 -2
  39. package/fesm/controllers/user-permission.controller.js +9 -1
  40. package/fesm/controllers/user.controller.js +16 -4
  41. package/fesm/dtos/authentication.dto.js +8 -0
  42. package/fesm/dtos/user-permission.dto.js +14 -0
  43. package/fesm/interceptors/set-token.interceptor.js +14 -4
  44. package/fesm/services/auth-config.service.js +10 -9
  45. package/fesm/services/auth-datasource.provider.js +7 -4
  46. package/fesm/services/auth-email.service.js +156 -45
  47. package/fesm/services/authentication.service.js +297 -61
  48. package/fesm/services/branch.service.js +1 -1
  49. package/fesm/services/company-selection-session.service.js +25 -6
  50. package/fesm/services/company.service.js +1 -1
  51. package/fesm/services/user-permission.service.js +52 -4
  52. package/fesm/services/user.service.js +122 -25
  53. package/fesm/strategies/jwt.strategy.js +18 -4
  54. package/interfaces/auth-module-options.interface.d.ts +2 -2
  55. package/interfaces/authentication.interface.d.ts +1 -0
  56. package/modules/auth.module.d.ts +2 -1
  57. package/package.json +3 -3
  58. package/services/auth-config.service.d.ts +0 -2
  59. package/services/auth-datasource.provider.d.ts +1 -3
  60. package/services/auth-email.service.d.ts +6 -3
  61. package/services/authentication.service.d.ts +5 -2
  62. package/services/branch.service.d.ts +2 -1
  63. package/services/user.service.d.ts +7 -7
@@ -0,0 +1,218 @@
1
+ export declare const AUTH_MESSAGES: {
2
+ readonly LOGIN_SUCCESS: "auth.login.success";
3
+ readonly LOGIN_FAILED: "auth.login.failed";
4
+ readonly LOGIN_INVALID_CREDENTIALS: "auth.login.invalid.credentials";
5
+ readonly LOGIN_EMAIL_NOT_VERIFIED: "auth.login.email.not.verified";
6
+ readonly LOGIN_REQUIRES_SELECTION: "auth.login.requires.selection";
7
+ readonly LOGIN_ACCOUNT_DEACTIVATED: "auth.login.account.deactivated";
8
+ readonly LOGOUT_SUCCESS: "auth.logout.success";
9
+ readonly REGISTER_SUCCESS: "auth.register.success";
10
+ readonly REGISTER_FAILED: "auth.register.failed";
11
+ readonly REGISTER_EMAIL_EXISTS: "auth.register.email.exists";
12
+ readonly REGISTER_COMPANY_ALREADY_ASSIGNED: "auth.register.company.already.assigned";
13
+ readonly PASSWORD_CHANGE_SUCCESS: "auth.password.change.success";
14
+ readonly PASSWORD_CHANGE_FAILED: "auth.password.change.failed";
15
+ readonly PASSWORD_CHANGE_INVALID_CURRENT: "auth.password.change.invalid.current";
16
+ readonly PASSWORD_CHANGE_CURRENT_REQUIRED: "auth.password.change.current.required";
17
+ readonly PASSWORD_RESET_EMAIL_SENT: "auth.password.reset.email.sent";
18
+ readonly PASSWORD_RESET_SUCCESS: "auth.password.reset.success";
19
+ readonly PASSWORD_RESET_FAILED: "auth.password.reset.failed";
20
+ readonly TOKEN_REFRESH_SUCCESS: "auth.token.refresh.success";
21
+ readonly TOKEN_REQUIRED: "auth.token.required";
22
+ readonly TOKEN_INVALID: "auth.token.invalid";
23
+ readonly TOKEN_EXPIRED: "auth.token.expired";
24
+ readonly TOKEN_REVOKED: "auth.token.revoked";
25
+ readonly TOKEN_TOO_LARGE: "auth.token.too.large";
26
+ readonly COMPANY_SELECT_SUCCESS: "auth.company.select.success";
27
+ readonly COMPANY_SWITCH_SUCCESS: "auth.company.switch.success";
28
+ readonly COMPANY_LIST_SUCCESS: "auth.company.list.success";
29
+ readonly COMPANY_NO_ACCESS: "auth.company.no.access";
30
+ readonly COMPANY_NOT_FOUND: "auth.company.not.found";
31
+ readonly COMPANY_REQUIRED: "auth.company.required";
32
+ readonly COMPANY_FEATURE_NOT_ENABLED: "auth.company.feature.not.enabled";
33
+ readonly BRANCH_LIST_SUCCESS: "auth.branch.list.success";
34
+ readonly BRANCH_NO_ACCESS: "auth.branch.no.access";
35
+ readonly BRANCH_NOT_FOUND: "auth.branch.not.found";
36
+ readonly ME_SUCCESS: "auth.me.success";
37
+ readonly EMAIL_NOT_CONFIGURED: "auth.email.not.configured";
38
+ readonly EMAIL_SEND_FAILED: "auth.email.send.failed";
39
+ readonly SESSION_INVALID: "auth.session.invalid";
40
+ readonly SESSION_NOT_AVAILABLE: "auth.session.not.available";
41
+ readonly PROFILE_ACCESS_DENIED: "auth.profile.access.denied";
42
+ readonly PROFILE_SECTIONS_NOT_SUPPORTED: "auth.profile.sections.not.supported";
43
+ readonly LOGOUT_SERVICE_UNAVAILABLE: "auth.logout.service.unavailable";
44
+ readonly PASSWORD_RESET_TOKEN_EXPIRED: "auth.password.reset.token.expired";
45
+ readonly PASSWORD_RESET_TOKEN_USED: "auth.password.reset.token.used";
46
+ };
47
+ export declare const EMAIL_VERIFICATION_MESSAGES: {
48
+ readonly VERIFICATION_SENT: "email.verification.sent";
49
+ readonly VERIFICATION_SUCCESS: "email.verification.success";
50
+ readonly VERIFICATION_FAILED: "email.verification.failed";
51
+ readonly VERIFICATION_TOKEN_INVALID: "email.verification.token.invalid";
52
+ readonly VERIFICATION_TOKEN_EXPIRED: "email.verification.token.expired";
53
+ readonly VERIFICATION_NOT_ENABLED: "email.verification.not.enabled";
54
+ readonly RESEND_SUCCESS: "email.verification.resend.success";
55
+ readonly RESEND_THROTTLED: "email.verification.resend.throttled";
56
+ };
57
+ export declare const USER_MESSAGES: {
58
+ readonly CREATE_SUCCESS: "user.create.success";
59
+ readonly CREATE_MANY_SUCCESS: "user.create.many.success";
60
+ readonly GET_SUCCESS: "user.get.success";
61
+ readonly GET_ALL_SUCCESS: "user.get.all.success";
62
+ readonly UPDATE_SUCCESS: "user.update.success";
63
+ readonly UPDATE_MANY_SUCCESS: "user.update.many.success";
64
+ readonly DELETE_SUCCESS: "user.delete.success";
65
+ readonly RESTORE_SUCCESS: "user.restore.success";
66
+ readonly NOT_FOUND: "user.not.found";
67
+ readonly PROFILE_SUCCESS: "user.profile.success";
68
+ readonly PROFILE_UPDATE_SUCCESS: "user.profile.update.success";
69
+ readonly PROFILE_EXTRAS_SUCCESS: "user.profile.extras.success";
70
+ readonly PROFILE_SECTIONS_SUCCESS: "user.profile.sections.success";
71
+ readonly PROFILE_SECTION_DATA_SUCCESS: "user.profile.section.data.success";
72
+ readonly PROFILE_SECTION_UPDATE_SUCCESS: "user.profile.section.update.success";
73
+ readonly PROFILE_COMPLETION_SUCCESS: "user.profile.completion.success";
74
+ readonly EMAIL_VERIFY_SUCCESS: "user.email.verify.success";
75
+ readonly PHONE_VERIFY_SUCCESS: "user.phone.verify.success";
76
+ readonly STATUS_UPDATE_SUCCESS: "user.status.update.success";
77
+ };
78
+ export declare const COMPANY_MESSAGES: {
79
+ readonly CREATE_SUCCESS: "company.create.success";
80
+ readonly CREATE_MANY_SUCCESS: "company.create.many.success";
81
+ readonly GET_SUCCESS: "company.get.success";
82
+ readonly GET_ALL_SUCCESS: "company.get.all.success";
83
+ readonly UPDATE_SUCCESS: "company.update.success";
84
+ readonly UPDATE_MANY_SUCCESS: "company.update.many.success";
85
+ readonly DELETE_SUCCESS: "company.delete.success";
86
+ readonly RESTORE_SUCCESS: "company.restore.success";
87
+ readonly NOT_FOUND: "company.not.found";
88
+ };
89
+ export declare const BRANCH_MESSAGES: {
90
+ readonly CREATE_SUCCESS: "branch.create.success";
91
+ readonly CREATE_MANY_SUCCESS: "branch.create.many.success";
92
+ readonly GET_SUCCESS: "branch.get.success";
93
+ readonly GET_ALL_SUCCESS: "branch.get.all.success";
94
+ readonly UPDATE_SUCCESS: "branch.update.success";
95
+ readonly UPDATE_MANY_SUCCESS: "branch.update.many.success";
96
+ readonly DELETE_SUCCESS: "branch.delete.success";
97
+ readonly RESTORE_SUCCESS: "branch.restore.success";
98
+ readonly NOT_FOUND: "branch.not.found";
99
+ };
100
+ export declare const USER_PERMISSION_MESSAGES: {
101
+ readonly COMPANY_ASSIGN_SUCCESS: "user.permission.company.assign.success";
102
+ readonly COMPANY_LIST_SUCCESS: "user.permission.company.list.success";
103
+ readonly BRANCH_ASSIGN_SUCCESS: "user.permission.branch.assign.success";
104
+ readonly BRANCH_LIST_SUCCESS: "user.permission.branch.list.success";
105
+ readonly BATCH_SUCCESS: "user.permission.batch.success";
106
+ readonly ALREADY_ASSIGNED: "user.permission.already.assigned";
107
+ readonly PERMISSION_NOT_FOUND: "user.permission.not.found";
108
+ };
109
+ export declare const AUTH_MODULE_MESSAGES: {
110
+ readonly AUTH: {
111
+ readonly LOGIN_SUCCESS: "auth.login.success";
112
+ readonly LOGIN_FAILED: "auth.login.failed";
113
+ readonly LOGIN_INVALID_CREDENTIALS: "auth.login.invalid.credentials";
114
+ readonly LOGIN_EMAIL_NOT_VERIFIED: "auth.login.email.not.verified";
115
+ readonly LOGIN_REQUIRES_SELECTION: "auth.login.requires.selection";
116
+ readonly LOGIN_ACCOUNT_DEACTIVATED: "auth.login.account.deactivated";
117
+ readonly LOGOUT_SUCCESS: "auth.logout.success";
118
+ readonly REGISTER_SUCCESS: "auth.register.success";
119
+ readonly REGISTER_FAILED: "auth.register.failed";
120
+ readonly REGISTER_EMAIL_EXISTS: "auth.register.email.exists";
121
+ readonly REGISTER_COMPANY_ALREADY_ASSIGNED: "auth.register.company.already.assigned";
122
+ readonly PASSWORD_CHANGE_SUCCESS: "auth.password.change.success";
123
+ readonly PASSWORD_CHANGE_FAILED: "auth.password.change.failed";
124
+ readonly PASSWORD_CHANGE_INVALID_CURRENT: "auth.password.change.invalid.current";
125
+ readonly PASSWORD_CHANGE_CURRENT_REQUIRED: "auth.password.change.current.required";
126
+ readonly PASSWORD_RESET_EMAIL_SENT: "auth.password.reset.email.sent";
127
+ readonly PASSWORD_RESET_SUCCESS: "auth.password.reset.success";
128
+ readonly PASSWORD_RESET_FAILED: "auth.password.reset.failed";
129
+ readonly TOKEN_REFRESH_SUCCESS: "auth.token.refresh.success";
130
+ readonly TOKEN_REQUIRED: "auth.token.required";
131
+ readonly TOKEN_INVALID: "auth.token.invalid";
132
+ readonly TOKEN_EXPIRED: "auth.token.expired";
133
+ readonly TOKEN_REVOKED: "auth.token.revoked";
134
+ readonly TOKEN_TOO_LARGE: "auth.token.too.large";
135
+ readonly COMPANY_SELECT_SUCCESS: "auth.company.select.success";
136
+ readonly COMPANY_SWITCH_SUCCESS: "auth.company.switch.success";
137
+ readonly COMPANY_LIST_SUCCESS: "auth.company.list.success";
138
+ readonly COMPANY_NO_ACCESS: "auth.company.no.access";
139
+ readonly COMPANY_NOT_FOUND: "auth.company.not.found";
140
+ readonly COMPANY_REQUIRED: "auth.company.required";
141
+ readonly COMPANY_FEATURE_NOT_ENABLED: "auth.company.feature.not.enabled";
142
+ readonly BRANCH_LIST_SUCCESS: "auth.branch.list.success";
143
+ readonly BRANCH_NO_ACCESS: "auth.branch.no.access";
144
+ readonly BRANCH_NOT_FOUND: "auth.branch.not.found";
145
+ readonly ME_SUCCESS: "auth.me.success";
146
+ readonly EMAIL_NOT_CONFIGURED: "auth.email.not.configured";
147
+ readonly EMAIL_SEND_FAILED: "auth.email.send.failed";
148
+ readonly SESSION_INVALID: "auth.session.invalid";
149
+ readonly SESSION_NOT_AVAILABLE: "auth.session.not.available";
150
+ readonly PROFILE_ACCESS_DENIED: "auth.profile.access.denied";
151
+ readonly PROFILE_SECTIONS_NOT_SUPPORTED: "auth.profile.sections.not.supported";
152
+ readonly LOGOUT_SERVICE_UNAVAILABLE: "auth.logout.service.unavailable";
153
+ readonly PASSWORD_RESET_TOKEN_EXPIRED: "auth.password.reset.token.expired";
154
+ readonly PASSWORD_RESET_TOKEN_USED: "auth.password.reset.token.used";
155
+ };
156
+ readonly EMAIL_VERIFICATION: {
157
+ readonly VERIFICATION_SENT: "email.verification.sent";
158
+ readonly VERIFICATION_SUCCESS: "email.verification.success";
159
+ readonly VERIFICATION_FAILED: "email.verification.failed";
160
+ readonly VERIFICATION_TOKEN_INVALID: "email.verification.token.invalid";
161
+ readonly VERIFICATION_TOKEN_EXPIRED: "email.verification.token.expired";
162
+ readonly VERIFICATION_NOT_ENABLED: "email.verification.not.enabled";
163
+ readonly RESEND_SUCCESS: "email.verification.resend.success";
164
+ readonly RESEND_THROTTLED: "email.verification.resend.throttled";
165
+ };
166
+ readonly USER: {
167
+ readonly CREATE_SUCCESS: "user.create.success";
168
+ readonly CREATE_MANY_SUCCESS: "user.create.many.success";
169
+ readonly GET_SUCCESS: "user.get.success";
170
+ readonly GET_ALL_SUCCESS: "user.get.all.success";
171
+ readonly UPDATE_SUCCESS: "user.update.success";
172
+ readonly UPDATE_MANY_SUCCESS: "user.update.many.success";
173
+ readonly DELETE_SUCCESS: "user.delete.success";
174
+ readonly RESTORE_SUCCESS: "user.restore.success";
175
+ readonly NOT_FOUND: "user.not.found";
176
+ readonly PROFILE_SUCCESS: "user.profile.success";
177
+ readonly PROFILE_UPDATE_SUCCESS: "user.profile.update.success";
178
+ readonly PROFILE_EXTRAS_SUCCESS: "user.profile.extras.success";
179
+ readonly PROFILE_SECTIONS_SUCCESS: "user.profile.sections.success";
180
+ readonly PROFILE_SECTION_DATA_SUCCESS: "user.profile.section.data.success";
181
+ readonly PROFILE_SECTION_UPDATE_SUCCESS: "user.profile.section.update.success";
182
+ readonly PROFILE_COMPLETION_SUCCESS: "user.profile.completion.success";
183
+ readonly EMAIL_VERIFY_SUCCESS: "user.email.verify.success";
184
+ readonly PHONE_VERIFY_SUCCESS: "user.phone.verify.success";
185
+ readonly STATUS_UPDATE_SUCCESS: "user.status.update.success";
186
+ };
187
+ readonly COMPANY: {
188
+ readonly CREATE_SUCCESS: "company.create.success";
189
+ readonly CREATE_MANY_SUCCESS: "company.create.many.success";
190
+ readonly GET_SUCCESS: "company.get.success";
191
+ readonly GET_ALL_SUCCESS: "company.get.all.success";
192
+ readonly UPDATE_SUCCESS: "company.update.success";
193
+ readonly UPDATE_MANY_SUCCESS: "company.update.many.success";
194
+ readonly DELETE_SUCCESS: "company.delete.success";
195
+ readonly RESTORE_SUCCESS: "company.restore.success";
196
+ readonly NOT_FOUND: "company.not.found";
197
+ };
198
+ readonly BRANCH: {
199
+ readonly CREATE_SUCCESS: "branch.create.success";
200
+ readonly CREATE_MANY_SUCCESS: "branch.create.many.success";
201
+ readonly GET_SUCCESS: "branch.get.success";
202
+ readonly GET_ALL_SUCCESS: "branch.get.all.success";
203
+ readonly UPDATE_SUCCESS: "branch.update.success";
204
+ readonly UPDATE_MANY_SUCCESS: "branch.update.many.success";
205
+ readonly DELETE_SUCCESS: "branch.delete.success";
206
+ readonly RESTORE_SUCCESS: "branch.restore.success";
207
+ readonly NOT_FOUND: "branch.not.found";
208
+ };
209
+ readonly USER_PERMISSION: {
210
+ readonly COMPANY_ASSIGN_SUCCESS: "user.permission.company.assign.success";
211
+ readonly COMPANY_LIST_SUCCESS: "user.permission.company.list.success";
212
+ readonly BRANCH_ASSIGN_SUCCESS: "user.permission.branch.assign.success";
213
+ readonly BRANCH_LIST_SUCCESS: "user.permission.branch.list.success";
214
+ readonly BATCH_SUCCESS: "user.permission.batch.success";
215
+ readonly ALREADY_ASSIGNED: "user.permission.already.assigned";
216
+ readonly PERMISSION_NOT_FOUND: "user.permission.not.found";
217
+ };
218
+ };
@@ -8,11 +8,13 @@ export declare class CompanySelectionController {
8
8
  getUserCompanies(userId: string): Promise<{
9
9
  success: boolean;
10
10
  message: string;
11
+ messageKey: "auth.company.list.success";
11
12
  data: import("..").Company[];
12
13
  }>;
13
14
  getUserBranches(userId: string, companyId: string): Promise<{
14
15
  success: boolean;
15
16
  message: string;
17
+ messageKey: "auth.branch.list.success";
16
18
  data: import("..").CompanyBranch[];
17
19
  }>;
18
20
  }
@@ -6,11 +6,15 @@ export declare class UserPermissionController {
6
6
  assignUserCompany(dto: AssignUserCompanyDto): Promise<{
7
7
  success: boolean;
8
8
  message: string;
9
+ messageKey: string;
10
+ messageVariables: Record<string, number>;
9
11
  }>;
10
12
  getUserCompanies(userId: string): Promise<UserCompaniesResponseDto>;
11
13
  assignUserBranch(dto: AssignUserBranchDto): Promise<{
12
14
  success: boolean;
13
15
  message: string;
16
+ messageKey: string;
17
+ messageVariables: Record<string, number>;
14
18
  }>;
15
19
  getUserBranches(userId: string, companyId?: string): Promise<UserBranchesResponseDto>;
16
20
  private processBatchPermissions;
@@ -17,6 +17,8 @@ export declare class UserController extends UserController_base {
17
17
  constructor(service: UserService);
18
18
  getProfileWithExtras(id: string, user: ILoggedUserInfo): Promise<{
19
19
  success: boolean;
20
+ message: string;
21
+ messageKey: "user.profile.extras.success";
20
22
  data: {
21
23
  user: IUser;
22
24
  extras?: import("..").IProfileExtras;
@@ -25,37 +27,45 @@ export declare class UserController extends UserController_base {
25
27
  verifyEmail(id: string): Promise<{
26
28
  success: boolean;
27
29
  message: string;
30
+ messageKey: "user.email.verify.success";
28
31
  }>;
29
32
  verifyPhone(id: string): Promise<{
30
33
  success: boolean;
31
34
  message: string;
35
+ messageKey: "user.phone.verify.success";
32
36
  }>;
33
37
  updateStatus(id: string, isActive: boolean, user: ILoggedUserInfo): Promise<{
34
38
  success: boolean;
35
39
  message: string;
40
+ messageKey: "user.status.update.success";
36
41
  }>;
37
42
  profile(dto: UpdateUserDto, user: ILoggedUserInfo): Promise<{
38
43
  success: boolean;
39
44
  message: string;
45
+ messageKey: "user.profile.update.success";
40
46
  data: string;
41
47
  }>;
42
48
  getProfileSections(): Promise<{
43
49
  success: boolean;
44
50
  message: string;
51
+ messageKey: "user.profile.sections.success";
45
52
  data: import("..").IProfileSection[];
46
53
  }>;
47
54
  getProfileSectionData(id: string, sectionId: string, user: ILoggedUserInfo): Promise<{
48
55
  success: boolean;
49
56
  message: string;
57
+ messageKey: "user.profile.section.data.success";
50
58
  data: import("..").IProfileSectionData;
51
59
  }>;
52
60
  updateProfileSection(id: string, sectionId: string, data: Record<string, any>, user: ILoggedUserInfo): Promise<{
53
61
  success: boolean;
54
62
  message: string;
63
+ messageKey: "user.profile.section.update.success";
55
64
  }>;
56
65
  getProfileCompletion(id: string, user: ILoggedUserInfo): Promise<{
57
66
  success: boolean;
58
67
  message: string;
68
+ messageKey: "user.profile.completion.success";
59
69
  data: {
60
70
  completionPercentage: number;
61
71
  };
@@ -92,6 +92,7 @@ export declare class LoginResponseRequiresEmailVerificationDto {
92
92
  requiresEmailVerification: true;
93
93
  email: string;
94
94
  message: string;
95
+ messageKey: string;
95
96
  }
96
97
  export declare class ForgotPasswordDto {
97
98
  email: string;
@@ -28,10 +28,12 @@ export declare class UserBranchPermissionDto {
28
28
  export declare class UserCompaniesResponseDto {
29
29
  success: boolean;
30
30
  message: string;
31
+ messageKey: string;
31
32
  data: UserCompanyPermissionDto[];
32
33
  }
33
34
  export declare class UserBranchesResponseDto {
34
35
  success: boolean;
35
36
  message: string;
37
+ messageKey: string;
36
38
  data: UserBranchPermissionDto[];
37
39
  }
@@ -4,8 +4,17 @@ export * from './pending-registration.entity';
4
4
  export { PermissionType, UserCompanyPermission } from './user-company-permission.entity';
5
5
  export * from './user.entity';
6
6
  export * from './user-token.entity';
7
+ import { CompanyBranch } from './company-branch.entity';
8
+ import { Company } from './company.entity';
9
+ import { PendingRegistration } from './pending-registration.entity';
10
+ import { UserCompanyPermission } from './user-company-permission.entity';
11
+ import { User } from './user.entity';
12
+ import { UserToken } from './user-token.entity';
13
+ declare const BaseEntities: (typeof User | typeof UserToken)[];
14
+ declare const EmailEntities: (typeof PendingRegistration)[];
15
+ declare const CompanyEntities: (typeof Company | typeof CompanyBranch | typeof UserCompanyPermission)[];
7
16
  export interface IAuthEntitiesConfig {
8
17
  enableCompanyFeature?: boolean;
9
18
  enableEmailVerification?: boolean;
10
19
  }
11
- export declare function getEntitiesByConfig(config: IAuthEntitiesConfig): any[];
20
+ export declare function getEntitiesByConfig(config: IAuthEntitiesConfig): (typeof BaseEntities[number] | typeof EmailEntities[number] | typeof CompanyEntities[number])[];
@@ -1 +1,2 @@
1
1
  export * from './auth.constants';
2
+ export * from './message-keys';
@@ -0,0 +1,118 @@
1
+ // ==================== AUTH MODULE MESSAGE KEYS ====================
2
+ export const AUTH_MESSAGES = {
3
+ LOGIN_SUCCESS: 'auth.login.success',
4
+ LOGIN_FAILED: 'auth.login.failed',
5
+ LOGIN_INVALID_CREDENTIALS: 'auth.login.invalid.credentials',
6
+ LOGIN_EMAIL_NOT_VERIFIED: 'auth.login.email.not.verified',
7
+ LOGIN_REQUIRES_SELECTION: 'auth.login.requires.selection',
8
+ LOGIN_ACCOUNT_DEACTIVATED: 'auth.login.account.deactivated',
9
+ LOGOUT_SUCCESS: 'auth.logout.success',
10
+ REGISTER_SUCCESS: 'auth.register.success',
11
+ REGISTER_FAILED: 'auth.register.failed',
12
+ REGISTER_EMAIL_EXISTS: 'auth.register.email.exists',
13
+ REGISTER_COMPANY_ALREADY_ASSIGNED: 'auth.register.company.already.assigned',
14
+ PASSWORD_CHANGE_SUCCESS: 'auth.password.change.success',
15
+ PASSWORD_CHANGE_FAILED: 'auth.password.change.failed',
16
+ PASSWORD_CHANGE_INVALID_CURRENT: 'auth.password.change.invalid.current',
17
+ PASSWORD_CHANGE_CURRENT_REQUIRED: 'auth.password.change.current.required',
18
+ PASSWORD_RESET_EMAIL_SENT: 'auth.password.reset.email.sent',
19
+ PASSWORD_RESET_SUCCESS: 'auth.password.reset.success',
20
+ PASSWORD_RESET_FAILED: 'auth.password.reset.failed',
21
+ TOKEN_REFRESH_SUCCESS: 'auth.token.refresh.success',
22
+ TOKEN_REQUIRED: 'auth.token.required',
23
+ TOKEN_INVALID: 'auth.token.invalid',
24
+ TOKEN_EXPIRED: 'auth.token.expired',
25
+ TOKEN_REVOKED: 'auth.token.revoked',
26
+ TOKEN_TOO_LARGE: 'auth.token.too.large',
27
+ COMPANY_SELECT_SUCCESS: 'auth.company.select.success',
28
+ COMPANY_SWITCH_SUCCESS: 'auth.company.switch.success',
29
+ COMPANY_LIST_SUCCESS: 'auth.company.list.success',
30
+ COMPANY_NO_ACCESS: 'auth.company.no.access',
31
+ COMPANY_NOT_FOUND: 'auth.company.not.found',
32
+ COMPANY_REQUIRED: 'auth.company.required',
33
+ COMPANY_FEATURE_NOT_ENABLED: 'auth.company.feature.not.enabled',
34
+ BRANCH_LIST_SUCCESS: 'auth.branch.list.success',
35
+ BRANCH_NO_ACCESS: 'auth.branch.no.access',
36
+ BRANCH_NOT_FOUND: 'auth.branch.not.found',
37
+ ME_SUCCESS: 'auth.me.success',
38
+ EMAIL_NOT_CONFIGURED: 'auth.email.not.configured',
39
+ EMAIL_SEND_FAILED: 'auth.email.send.failed',
40
+ SESSION_INVALID: 'auth.session.invalid',
41
+ SESSION_NOT_AVAILABLE: 'auth.session.not.available',
42
+ PROFILE_ACCESS_DENIED: 'auth.profile.access.denied',
43
+ PROFILE_SECTIONS_NOT_SUPPORTED: 'auth.profile.sections.not.supported',
44
+ LOGOUT_SERVICE_UNAVAILABLE: 'auth.logout.service.unavailable',
45
+ PASSWORD_RESET_TOKEN_EXPIRED: 'auth.password.reset.token.expired',
46
+ PASSWORD_RESET_TOKEN_USED: 'auth.password.reset.token.used'
47
+ };
48
+ export const EMAIL_VERIFICATION_MESSAGES = {
49
+ VERIFICATION_SENT: 'email.verification.sent',
50
+ VERIFICATION_SUCCESS: 'email.verification.success',
51
+ VERIFICATION_FAILED: 'email.verification.failed',
52
+ VERIFICATION_TOKEN_INVALID: 'email.verification.token.invalid',
53
+ VERIFICATION_TOKEN_EXPIRED: 'email.verification.token.expired',
54
+ VERIFICATION_NOT_ENABLED: 'email.verification.not.enabled',
55
+ RESEND_SUCCESS: 'email.verification.resend.success',
56
+ RESEND_THROTTLED: 'email.verification.resend.throttled'
57
+ };
58
+ export const USER_MESSAGES = {
59
+ CREATE_SUCCESS: 'user.create.success',
60
+ CREATE_MANY_SUCCESS: 'user.create.many.success',
61
+ GET_SUCCESS: 'user.get.success',
62
+ GET_ALL_SUCCESS: 'user.get.all.success',
63
+ UPDATE_SUCCESS: 'user.update.success',
64
+ UPDATE_MANY_SUCCESS: 'user.update.many.success',
65
+ DELETE_SUCCESS: 'user.delete.success',
66
+ RESTORE_SUCCESS: 'user.restore.success',
67
+ NOT_FOUND: 'user.not.found',
68
+ PROFILE_SUCCESS: 'user.profile.success',
69
+ PROFILE_UPDATE_SUCCESS: 'user.profile.update.success',
70
+ PROFILE_EXTRAS_SUCCESS: 'user.profile.extras.success',
71
+ PROFILE_SECTIONS_SUCCESS: 'user.profile.sections.success',
72
+ PROFILE_SECTION_DATA_SUCCESS: 'user.profile.section.data.success',
73
+ PROFILE_SECTION_UPDATE_SUCCESS: 'user.profile.section.update.success',
74
+ PROFILE_COMPLETION_SUCCESS: 'user.profile.completion.success',
75
+ EMAIL_VERIFY_SUCCESS: 'user.email.verify.success',
76
+ PHONE_VERIFY_SUCCESS: 'user.phone.verify.success',
77
+ STATUS_UPDATE_SUCCESS: 'user.status.update.success'
78
+ };
79
+ export const COMPANY_MESSAGES = {
80
+ CREATE_SUCCESS: 'company.create.success',
81
+ CREATE_MANY_SUCCESS: 'company.create.many.success',
82
+ GET_SUCCESS: 'company.get.success',
83
+ GET_ALL_SUCCESS: 'company.get.all.success',
84
+ UPDATE_SUCCESS: 'company.update.success',
85
+ UPDATE_MANY_SUCCESS: 'company.update.many.success',
86
+ DELETE_SUCCESS: 'company.delete.success',
87
+ RESTORE_SUCCESS: 'company.restore.success',
88
+ NOT_FOUND: 'company.not.found'
89
+ };
90
+ export const BRANCH_MESSAGES = {
91
+ CREATE_SUCCESS: 'branch.create.success',
92
+ CREATE_MANY_SUCCESS: 'branch.create.many.success',
93
+ GET_SUCCESS: 'branch.get.success',
94
+ GET_ALL_SUCCESS: 'branch.get.all.success',
95
+ UPDATE_SUCCESS: 'branch.update.success',
96
+ UPDATE_MANY_SUCCESS: 'branch.update.many.success',
97
+ DELETE_SUCCESS: 'branch.delete.success',
98
+ RESTORE_SUCCESS: 'branch.restore.success',
99
+ NOT_FOUND: 'branch.not.found'
100
+ };
101
+ export const USER_PERMISSION_MESSAGES = {
102
+ COMPANY_ASSIGN_SUCCESS: 'user.permission.company.assign.success',
103
+ COMPANY_LIST_SUCCESS: 'user.permission.company.list.success',
104
+ BRANCH_ASSIGN_SUCCESS: 'user.permission.branch.assign.success',
105
+ BRANCH_LIST_SUCCESS: 'user.permission.branch.list.success',
106
+ BATCH_SUCCESS: 'user.permission.batch.success',
107
+ ALREADY_ASSIGNED: 'user.permission.already.assigned',
108
+ PERMISSION_NOT_FOUND: 'user.permission.not.found'
109
+ };
110
+ // Aggregated export for backward compatibility
111
+ export const AUTH_MODULE_MESSAGES = {
112
+ AUTH: AUTH_MESSAGES,
113
+ EMAIL_VERIFICATION: EMAIL_VERIFICATION_MESSAGES,
114
+ USER: USER_MESSAGES,
115
+ COMPANY: COMPANY_MESSAGES,
116
+ BRANCH: BRANCH_MESSAGES,
117
+ USER_PERMISSION: USER_PERMISSION_MESSAGES
118
+ };
@@ -25,6 +25,7 @@ function _ts_param(paramIndex, decorator) {
25
25
  decorator(target, key, paramIndex);
26
26
  };
27
27
  }
28
+ import { AUTH_MESSAGES } from '../config';
28
29
  import { CurrentUser } from '@flusys/nestjs-shared/decorators';
29
30
  import { MessageResponseDto } from '@flusys/nestjs-shared/dtos';
30
31
  import { JwtAuthGuard } from '@flusys/nestjs-shared/guards';
@@ -68,7 +69,10 @@ export class AuthenticationController {
68
69
  // Always check cookie first, then body - handles Browser, SSR, and Mobile/API
69
70
  const refreshToken = req.cookies?.[cookieName] || refreshTokenDto.refreshToken;
70
71
  if (!refreshToken) {
71
- throw new UnauthorizedException('Refresh token is required');
72
+ throw new UnauthorizedException({
73
+ message: 'Refresh token is required',
74
+ messageKey: AUTH_MESSAGES.TOKEN_REQUIRED
75
+ });
72
76
  }
73
77
  return this.authService.refreshToken(refreshToken);
74
78
  }
@@ -79,14 +83,16 @@ export class AuthenticationController {
79
83
  await this.authService.logout(userId);
80
84
  return {
81
85
  success: true,
82
- message: 'Logged out successfully'
86
+ message: 'Logged out successfully',
87
+ messageKey: AUTH_MESSAGES.LOGOUT_SUCCESS
83
88
  };
84
89
  }
85
90
  async changePassword(userId, dto) {
86
91
  await this.authService.changePassword(userId, dto.currentPassword, dto.newPassword);
87
92
  return {
88
93
  success: true,
89
- message: 'Password changed successfully'
94
+ message: 'Password changed successfully',
95
+ messageKey: AUTH_MESSAGES.PASSWORD_CHANGE_SUCCESS
90
96
  };
91
97
  }
92
98
  constructor(authService, authConfig){
@@ -31,6 +31,7 @@ import { ApiTags } from '@nestjs/swagger';
31
31
  import { CompanyBranchResponseDto, CreateCompanyBranchDto, UpdateCompanyBranchDto } from '../dtos/company-branch.dto';
32
32
  import { BranchService } from '../services/branch.service';
33
33
  export class BranchController extends createApiController(CreateCompanyBranchDto, UpdateCompanyBranchDto, CompanyBranchResponseDto, {
34
+ entityName: 'branch',
34
35
  security: {
35
36
  insert: {
36
37
  level: 'permission',
@@ -25,6 +25,7 @@ function _ts_param(paramIndex, decorator) {
25
25
  decorator(target, key, paramIndex);
26
26
  };
27
27
  }
28
+ import { AUTH_MESSAGES } from '../config';
28
29
  import { CurrentUser } from '@flusys/nestjs-shared/decorators';
29
30
  import { Body, Controller, HttpCode, HttpStatus, Inject, Post, UseGuards, UseInterceptors } from '@nestjs/common';
30
31
  import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
@@ -44,6 +45,7 @@ export class CompanySelectionController {
44
45
  return {
45
46
  success: true,
46
47
  message: 'User companies retrieved successfully',
48
+ messageKey: AUTH_MESSAGES.COMPANY_LIST_SUCCESS,
47
49
  data: companies
48
50
  };
49
51
  }
@@ -52,6 +54,7 @@ export class CompanySelectionController {
52
54
  return {
53
55
  success: true,
54
56
  message: 'Company branches retrieved successfully',
57
+ messageKey: AUTH_MESSAGES.BRANCH_LIST_SUCCESS,
55
58
  data: branches
56
59
  };
57
60
  }
@@ -31,6 +31,7 @@ import { ApiTags } from '@nestjs/swagger';
31
31
  import { CompanyResponseDto, CreateCompanyDto, UpdateCompanyDto } from '../dtos/company.dto';
32
32
  import { CompanyService } from '../services/company.service';
33
33
  export class CompanyController extends createApiController(CreateCompanyDto, UpdateCompanyDto, CompanyResponseDto, {
34
+ entityName: 'company',
34
35
  security: {
35
36
  insert: {
36
37
  level: 'permission',
@@ -25,6 +25,7 @@ function _ts_param(paramIndex, decorator) {
25
25
  decorator(target, key, paramIndex);
26
26
  };
27
27
  }
28
+ import { EMAIL_VERIFICATION_MESSAGES } from '../config';
28
29
  import { MessageResponseDto } from '@flusys/nestjs-shared/dtos';
29
30
  import { BadRequestException, Body, Controller, HttpCode, HttpStatus, Inject, Post, Req, UseInterceptors } from '@nestjs/common';
30
31
  import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
@@ -39,7 +40,10 @@ import { AuthenticationService } from '../services/authentication.service';
39
40
  export class EmailVerificationController {
40
41
  ensureEmailVerificationEnabled() {
41
42
  if (!this.dataSourceProvider.isEmailVerificationEnabled()) {
42
- throw new BadRequestException('Email verification is not enabled for this tenant');
43
+ throw new BadRequestException({
44
+ message: 'Email verification is not enabled for this tenant',
45
+ messageKey: EMAIL_VERIFICATION_MESSAGES.VERIFICATION_NOT_ENABLED
46
+ });
43
47
  }
44
48
  }
45
49
  buildAuthUrl(req, path) {
@@ -66,7 +70,8 @@ export class EmailVerificationController {
66
70
  }
67
71
  return {
68
72
  success: true,
69
- message: result.message
73
+ message: result.message,
74
+ messageKey: result.messageKey
70
75
  };
71
76
  }
72
77
  constructor(authService, authEmailService, authConfig, dataSourceProvider){
@@ -26,6 +26,7 @@ function _ts_param(paramIndex, decorator) {
26
26
  };
27
27
  }
28
28
  import { JwtAuthGuard, RequirePermission, USER_PERMISSIONS } from '@flusys/nestjs-shared';
29
+ import { USER_PERMISSION_MESSAGES } from '../config';
29
30
  import { Body, Controller, Inject, Post, UseGuards } from '@nestjs/common';
30
31
  import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
31
32
  import { AssignUserBranchDto, AssignUserCompanyDto, UserBranchesResponseDto, UserCompaniesResponseDto } from '../dtos/user-permission.dto';
@@ -40,6 +41,7 @@ export class UserPermissionController {
40
41
  return {
41
42
  success: true,
42
43
  message: 'User companies retrieved successfully',
44
+ messageKey: USER_PERMISSION_MESSAGES.COMPANY_LIST_SUCCESS,
43
45
  data: permissions.map((p)=>({
44
46
  id: p.id,
45
47
  userId: p.userId,
@@ -57,6 +59,7 @@ export class UserPermissionController {
57
59
  return {
58
60
  success: true,
59
61
  message: 'User branches retrieved successfully',
62
+ messageKey: USER_PERMISSION_MESSAGES.BRANCH_LIST_SUCCESS,
60
63
  data: permissions.map((p)=>({
61
64
  id: p.id,
62
65
  userId: p.userId,
@@ -80,7 +83,12 @@ export class UserPermissionController {
80
83
  }
81
84
  return {
82
85
  success: true,
83
- message: `Processed ${added} additions and ${removed} removals`
86
+ message: `Processed ${added} additions and ${removed} removals`,
87
+ messageKey: USER_PERMISSION_MESSAGES.BATCH_SUCCESS,
88
+ messageVariables: {
89
+ added,
90
+ removed
91
+ }
84
92
  };
85
93
  }
86
94
  constructor(permissionService){