@tomei/sso 0.52.0 → 0.52.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/components/login-user/user.d.ts +3 -2
- package/dist/src/components/login-user/user.js +12 -8
- package/dist/src/components/login-user/user.js.map +1 -1
- package/dist/src/types/auth-context.d.ts +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/login-user/user.ts +29 -24
- package/src/types/auth-context.ts +2 -1
package/package.json
CHANGED
@@ -33,6 +33,7 @@ import { RedisService } from '../../redis-client/redis.service';
|
|
33
33
|
import { LoginUser } from './login-user';
|
34
34
|
import { SessionService } from '../../session/session.service';
|
35
35
|
import { createHash, randomBytes, randomUUID } from 'crypto';
|
36
|
+
import { AuthContext } from 'types';
|
36
37
|
|
37
38
|
export class User extends UserBase {
|
38
39
|
ObjectId: string;
|
@@ -2450,23 +2451,25 @@ export class User extends UserBase {
|
|
2450
2451
|
}
|
2451
2452
|
|
2452
2453
|
public static async findById(
|
2453
|
-
|
2454
|
+
AuthContext: AuthContext,
|
2454
2455
|
dbTransaction: any,
|
2455
2456
|
UserId: string,
|
2456
2457
|
) {
|
2457
2458
|
const systemCode = ApplicationConfig.getComponentConfigValue('system-code');
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
|
2462
|
-
|
2463
|
-
//If user does not have privilege to update user, throw a ClassError
|
2464
|
-
if (!isPrivileged) {
|
2465
|
-
throw new ClassError(
|
2466
|
-
'LoginUser',
|
2467
|
-
'LoginUserErrMsg0X',
|
2468
|
-
'You do not have the privilege to find user',
|
2459
|
+
if ('loginUser' in AuthContext) {
|
2460
|
+
const isPrivileged = await AuthContext.loginUser.checkPrivileges(
|
2461
|
+
systemCode,
|
2462
|
+
'USER_VIEW',
|
2469
2463
|
);
|
2464
|
+
|
2465
|
+
//If user does not have privilege to update user, throw a ClassError
|
2466
|
+
if (!isPrivileged) {
|
2467
|
+
throw new ClassError(
|
2468
|
+
'LoginUser',
|
2469
|
+
'LoginUserErrMsg0X',
|
2470
|
+
'You do not have the privilege to find user',
|
2471
|
+
);
|
2472
|
+
}
|
2470
2473
|
}
|
2471
2474
|
|
2472
2475
|
const user = await User._Repository.findOne({
|
@@ -2543,7 +2546,7 @@ export class User extends UserBase {
|
|
2543
2546
|
}
|
2544
2547
|
|
2545
2548
|
public static async findByEmail(
|
2546
|
-
|
2549
|
+
AuthContext: AuthContext,
|
2547
2550
|
dbTransaction: any,
|
2548
2551
|
Email: string,
|
2549
2552
|
): Promise<User> {
|
@@ -2555,18 +2558,20 @@ export class User extends UserBase {
|
|
2555
2558
|
// PrivilegeCode: "USER_VIEW"
|
2556
2559
|
const systemCode =
|
2557
2560
|
ApplicationConfig.getComponentConfigValue('system-code');
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
// If user does not have privilege to update user, throw a ClassError
|
2564
|
-
if (!isPrivileged) {
|
2565
|
-
throw new ClassError(
|
2566
|
-
'LoginUser',
|
2567
|
-
'LoginUserErrMsg0X',
|
2568
|
-
'You do not have the privilege to find user',
|
2561
|
+
if ('loginUser' in AuthContext) {
|
2562
|
+
const isPrivileged = await AuthContext.loginUser.checkPrivileges(
|
2563
|
+
systemCode,
|
2564
|
+
'USER_VIEW',
|
2569
2565
|
);
|
2566
|
+
|
2567
|
+
// If user does not have privilege to update user, throw a ClassError
|
2568
|
+
if (!isPrivileged) {
|
2569
|
+
throw new ClassError(
|
2570
|
+
'LoginUser',
|
2571
|
+
'LoginUserErrMsg0X',
|
2572
|
+
'You do not have the privilege to find user',
|
2573
|
+
);
|
2574
|
+
}
|
2570
2575
|
}
|
2571
2576
|
|
2572
2577
|
// Part 2: Retrieve User & Returns
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { IAPIKeyAttr } from '../interfaces/api-key-attr.interface';
|
1
2
|
import { LoginUser } from '../components/login-user/login-user';
|
2
3
|
|
3
4
|
export type AuthContext =
|
@@ -5,5 +6,5 @@ export type AuthContext =
|
|
5
6
|
loginUser: LoginUser;
|
6
7
|
}
|
7
8
|
| {
|
8
|
-
apiKey:
|
9
|
+
apiKey: IAPIKeyAttr;
|
9
10
|
};
|