@tomei/sso 0.35.1 → 0.35.3
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
@@ -1724,7 +1724,7 @@ export class User extends UserBase {
|
|
1724
1724
|
}
|
1725
1725
|
|
1726
1726
|
// 4. Generate the 2FA secret code by calling speakeasy.generateSecret with parameter
|
1727
|
-
const secretCode = speakeasy.generateSecret({ name:
|
1727
|
+
const secretCode = speakeasy.generateSecret({ name: 'Tomei 2FA' });
|
1728
1728
|
|
1729
1729
|
// parse MFA Config
|
1730
1730
|
let userMFAConfig = null;
|
@@ -2347,4 +2347,41 @@ export class User extends UserBase {
|
|
2347
2347
|
};
|
2348
2348
|
return new User(null, dbTransaction, userAttr);
|
2349
2349
|
}
|
2350
|
+
|
2351
|
+
public static async getFullName(dbTransaction: any, UserId: string) {
|
2352
|
+
try {
|
2353
|
+
// Part 1: Call User._Repo findById method by passing:
|
2354
|
+
// UserId
|
2355
|
+
// dbTransaction
|
2356
|
+
const user = await User._Repository.findOne({
|
2357
|
+
where: {
|
2358
|
+
UserId: UserId,
|
2359
|
+
},
|
2360
|
+
transaction: dbTransaction,
|
2361
|
+
});
|
2362
|
+
// Part 2: If no user found, throw new ClassError by passing:
|
2363
|
+
// Classname: "User"
|
2364
|
+
// MethodName: "getFullName"
|
2365
|
+
// MessageCode: "UserErrMsg0X"
|
2366
|
+
// Message: "No user found."
|
2367
|
+
if (!user) {
|
2368
|
+
throw new ClassError('User', 'UserErrMsg0X', 'No user found.');
|
2369
|
+
}
|
2370
|
+
|
2371
|
+
// Part 3: If user.FullName exists return user.FullName.
|
2372
|
+
if (user?.FullName) {
|
2373
|
+
return user?.FullName;
|
2374
|
+
}
|
2375
|
+
// Part 4: If user.Username exists return user.Username.
|
2376
|
+
else if (user?.UserName) {
|
2377
|
+
return user?.UserName;
|
2378
|
+
}
|
2379
|
+
// Part 5: Else return empty string.
|
2380
|
+
else {
|
2381
|
+
return '';
|
2382
|
+
}
|
2383
|
+
} catch (error) {
|
2384
|
+
throw error;
|
2385
|
+
}
|
2386
|
+
}
|
2350
2387
|
}
|