gemcap-be-common 1.4.17 → 1.4.18
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
|
@@ -31,7 +31,7 @@ interface IAuthConfig {
|
|
|
31
31
|
export declare class UsersService {
|
|
32
32
|
private readonly config;
|
|
33
33
|
constructor(config: IAuthConfig);
|
|
34
|
-
getUserAccessByRequest(req: express.Request): Promise<
|
|
34
|
+
getUserAccessByRequest(req: express.Request): Promise<IUserAccess | null>;
|
|
35
35
|
getUserById(userId: string): Promise<IUser>;
|
|
36
36
|
getUserByUsername(username: string): Promise<IUser>;
|
|
37
37
|
getUserByToken(req: express.Request): Promise<IUser>;
|
|
@@ -20,11 +20,11 @@ class UsersService {
|
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
const { sub } = (0, jwt_decode_1.jwtDecode)(authorization);
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
23
|
+
const userAccess = await this.getUserAccess(sub);
|
|
24
|
+
if (!userAccess) {
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
|
-
return
|
|
27
|
+
return userAccess;
|
|
28
28
|
}
|
|
29
29
|
async getUserById(userId) {
|
|
30
30
|
const { data } = await axios_1.default.get(`${this.config.baseUrl}/users/by-id/${userId}`);
|
|
@@ -18,17 +18,17 @@ export class UsersService {
|
|
|
18
18
|
this.config = config;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
async getUserAccessByRequest(req: express.Request): Promise<
|
|
21
|
+
async getUserAccessByRequest(req: express.Request): Promise<IUserAccess | null> {
|
|
22
22
|
const authorization = req.get('Authorization');
|
|
23
23
|
if (!authorization) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
const { sub }: { sub: string } = jwtDecode(authorization);
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
27
|
+
const userAccess = await this.getUserAccess(sub);
|
|
28
|
+
if (!userAccess) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return userAccess;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async getUserById(userId: string) {
|