@tomei/sso 0.34.5 → 0.34.6

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/sso",
3
- "version": "0.34.5",
3
+ "version": "0.34.6",
4
4
  "description": "Tomei SSO Package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -2285,4 +2285,59 @@ export class User extends UserBase {
2285
2285
  //Return Updated User Instance
2286
2286
  return this;
2287
2287
  }
2288
+
2289
+ public static async findById(
2290
+ loginUser: LoginUser,
2291
+ dbTransaction: any,
2292
+ UserId: string,
2293
+ ) {
2294
+ const systemCode = ApplicationConfig.getComponentConfigValue('system-code');
2295
+ const isPrivileged = await loginUser.checkPrivileges(
2296
+ systemCode,
2297
+ 'USER_VIEW',
2298
+ );
2299
+
2300
+ //If user does not have privilege to update user, throw a ClassError
2301
+ if (!isPrivileged) {
2302
+ throw new ClassError(
2303
+ 'LoginUser',
2304
+ 'LoginUserErrMsg0X',
2305
+ 'You do not have the privilege to find user',
2306
+ );
2307
+ }
2308
+
2309
+ const user = await User._Repository.findOne({
2310
+ where: {
2311
+ UserId: UserId,
2312
+ Status: 'Active',
2313
+ },
2314
+ transaction: dbTransaction,
2315
+ });
2316
+ const userAttr: IUserAttr = {
2317
+ UserId: user.UserId,
2318
+ UserName: user.UserName,
2319
+ FullName: user?.Staff?.FullName || null,
2320
+ IDNo: user?.Staff?.IdNo || null,
2321
+ ContactNo: user?.Staff?.Mobile || null,
2322
+ Email: user.Email,
2323
+ Password: user.Password,
2324
+ Status: user.Status,
2325
+ DefaultPasswordChangedYN: user.DefaultPasswordChangedYN,
2326
+ FirstLoginAt: user.FirstLoginAt,
2327
+ LastLoginAt: user.LastLoginAt,
2328
+ MFAEnabled: user.MFAEnabled,
2329
+ MFAConfig: user.MFAConfig,
2330
+ RecoveryEmail: user.RecoveryEmail,
2331
+ FailedLoginAttemptCount: user.FailedLoginAttemptCount,
2332
+ LastFailedLoginAt: user.LastFailedLoginAt,
2333
+ LastPasswordChangedAt: user.LastPasswordChangedAt,
2334
+ NeedToChangePasswordYN: user.NeedToChangePasswordYN,
2335
+ CreatedById: user.CreatedById,
2336
+ CreatedAt: user.CreatedAt,
2337
+ UpdatedById: user.UpdatedById,
2338
+ UpdatedAt: user.UpdatedAt,
2339
+ staffs: user?.Staff || null,
2340
+ };
2341
+ return new User(null, dbTransaction, userAttr);
2342
+ }
2288
2343
  }