@solidstarters/solid-core 1.2.116 → 1.2.117

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidstarters/solid-core",
3
- "version": "1.2.116",
3
+ "version": "1.2.117",
4
4
  "description": "This module is a NestJS module containing all the required core providers required by a Solid application",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@ export const iamConfig = registerAs('iam', () => {
12
12
  defaultRole: process.env.IAM_DEFAULT_ROLE ?? 'Public',
13
13
  dummyOtp: process.env.IAM_OTP_DUMMY,
14
14
  forgotPasswordSendVerificationTokenOn: process.env.IAM_FORGOT_PASSWORD_SEND_VERIFICATION_TOKEN_ON ?? 'email',
15
-
15
+ forceChangePasswordOnFirstLogin:true,
16
16
  googleOauth: {
17
17
  clientID: process.env.IAM_GOOGLE_OAUTH_CLIENT_ID,
18
18
  clientSecret: process.env.IAM_GOOGLE_OAUTH_CLIENT_SECRET,
@@ -8811,6 +8811,13 @@
8811
8811
  "label": "Iam Allow Public Registration"
8812
8812
  }
8813
8813
  },
8814
+ {
8815
+ "type": "field",
8816
+ "attrs": {
8817
+ "name": "forceChangePasswordOnFirstLogin",
8818
+ "label": "Force Password Change On First Login"
8819
+ }
8820
+ },
8814
8821
  {
8815
8822
  "type": "field",
8816
8823
  "attrs": {
@@ -82,6 +82,10 @@ export class AuthenticationService {
82
82
 
83
83
  ) { }
84
84
 
85
+ private async getConfig( key: string): Promise<any> {
86
+ return this.settingService.getConfigValue(key);
87
+ }
88
+
85
89
  private async getCompanyLogo(): Promise<string> {
86
90
  return await this.settingService.getConfigValue('companylogo');
87
91
  }
@@ -118,7 +122,7 @@ export class AuthenticationService {
118
122
 
119
123
  return user;
120
124
  }
121
-
125
+
122
126
  async signUp(signUpDto: SignUpDto, activeUser: ActiveUserData = null): Promise<User> {
123
127
  // If public registrations are disabled and no activeUser is present when invoking signUp then we throw an exception.
124
128
  if (!(await this.settingService.getConfigValue('allowPublicRegistration')) && !activeUser) {
@@ -126,9 +130,9 @@ export class AuthenticationService {
126
130
  }
127
131
 
128
132
  try {
129
- var { user, pwd, autoGeneratedPwd } = await this.populateForSignup(new User(), signUpDto, this.iamConfiguration.activateUserOnRegistration);
133
+ const onForcePasswordChange = await this.getConfig('forceChangePasswordOnFirstLogin');
134
+ var { user, pwd, autoGeneratedPwd } = await this.populateForSignup(new User(), signUpDto, this.iamConfiguration.activateUserOnRegistration,onForcePasswordChange);
130
135
  const savedUser = await this.userRepository.save(user);
131
-
132
136
  // Also assign a default role to the newly created user.
133
137
  const userRoles = signUpDto.roles ?? [];
134
138
  if (this.iamConfiguration.defaultRole) {
@@ -141,7 +145,7 @@ export class AuthenticationService {
141
145
  return savedUser;
142
146
  } catch (err) {
143
147
  const pgUniqueViolationErrorCode = '23505';
144
- if (err.code === pgUniqueViolationErrorCode) {
148
+ if (err.code === pgUniqueViolationErrorCode) {
145
149
  throw new ConflictException();
146
150
  }
147
151
  throw err;
@@ -150,10 +154,11 @@ export class AuthenticationService {
150
154
 
151
155
  async signupForExtensionUser<T extends User, U extends CreateUserDto>(signUpDto: SignUpDto, extensionUserDto: U, extensionUserRepo: Repository<T>): Promise<T> {
152
156
  try {
157
+ const onForcePasswordChange = await this.getConfig('forceChangePasswordOnFirstLogin');
153
158
  // Merge the extended signUpDto attributes into the user entity
154
159
  //@ts-ignore
155
160
  const extensionUser = extensionUserRepo.merge(extensionUserRepo.create() as T, extensionUserDto);
156
- var { user, pwd, autoGeneratedPwd } = await this.populateForSignup<T>(extensionUser, signUpDto);
161
+ var { user, pwd, autoGeneratedPwd } = await this.populateForSignup<T>(extensionUser, signUpDto,onForcePasswordChange);
157
162
  const savedUser = await extensionUserRepo.save(user);
158
163
 
159
164
  await this.handlePostSignup(savedUser, signUpDto.roles, pwd, autoGeneratedPwd);
@@ -170,7 +175,7 @@ export class AuthenticationService {
170
175
  }
171
176
 
172
177
 
173
- private async populateForSignup<T extends User>(user: T, signUpDto: SignUpDto, isUserActive: boolean = true) {
178
+ private async populateForSignup<T extends User>(user: T, signUpDto: SignUpDto, isUserActive: boolean = true,onForcePasswordChange?:boolean) {
174
179
  // const user = new User();
175
180
 
176
181
  if (signUpDto.roles && signUpDto.roles.length > 0) {
@@ -182,10 +187,11 @@ export class AuthenticationService {
182
187
  user.username = signUpDto.username;
183
188
  user.email = signUpDto.email;
184
189
  user.fullName = signUpDto.fullName;
190
+ user.forcePasswordChange = onForcePasswordChange;
185
191
  if (signUpDto.mobile) {
186
192
  user.mobile = signUpDto.mobile;
187
193
  }
188
-
194
+ this.logger.debug("user",user);
189
195
  // If password has been specified by the user, then we simply create & activate the user based on the configuration parameter "activateUserOnRegistration".
190
196
  let pwd = '';
191
197
  let autoGeneratedPwd = '';
@@ -146,7 +146,8 @@ export class SettingService extends CRUDService<Setting> {
146
146
  shouldQueueEmails: this.commonConfiguration.shouldQueueEmails,
147
147
  shouldQueueSms: this.commonConfiguration.shouldQueueSms,
148
148
  enableDarkMode: true,
149
- copyright : ""
149
+ copyright : "",
150
+ forceChangePasswordOnFirstLogin:true
150
151
  };
151
152
  }
152
153
 
@@ -154,7 +155,7 @@ export class SettingService extends CRUDService<Setting> {
154
155
  try {
155
156
  const settingsArray: Setting[] = await this.repo.find();
156
157
  const settingEntry = settingsArray.find(setting => setting.key === settingKey);
157
-
158
+
158
159
  if (settingEntry && settingEntry.value !== null && settingEntry.value !== undefined) {
159
160
  const value = settingEntry.value;
160
161