@plusscommunities/pluss-core-aws 2.0.1-auth.2 → 2.0.2-auth.0

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.
@@ -20,21 +20,21 @@ class AuthenticationContext {
20
20
 
21
21
  static getSessionUser = async (token) => {
22
22
  if (!AuthenticationContext.strategy) {
23
- throw new Error("Authentication strategy not initialised");
23
+ AuthenticationContext.initialiseStrategy();
24
24
  }
25
25
  return AuthenticationContext.strategy.getSessionUser(token);
26
26
  };
27
27
 
28
28
  static populateUser = async (token) => {
29
29
  if (!AuthenticationContext.strategy) {
30
- throw new Error("Authentication strategy not initialised");
30
+ AuthenticationContext.initialiseStrategy();
31
31
  }
32
32
  return AuthenticationContext.strategy.populateUser(token);
33
33
  };
34
34
 
35
35
  static updateIdentityAttributes = async (input, userId) => {
36
36
  if (!AuthenticationContext.strategy) {
37
- throw new Error("Authentication strategy not initialised");
37
+ AuthenticationContext.initialiseStrategy();
38
38
  }
39
39
  return AuthenticationContext.strategy.updateIdentityAttributes(
40
40
  input,
@@ -43,7 +43,4 @@ class AuthenticationContext {
43
43
  };
44
44
  }
45
45
 
46
- // Initialise the strategy based on configuration
47
- AuthenticationContext.initialiseStrategy();
48
-
49
46
  module.exports = AuthenticationContext;
@@ -5,7 +5,11 @@ const getSessionUser = async (token) => {
5
5
  return new Promise((resolve, reject) => {
6
6
  decodeAccessToken(token)
7
7
  .then((claims) => {
8
- return resolve(claims.pluss_id || claims.sub);
8
+ return resolve(
9
+ claims[getConfig().auth0Config.residentIdClaim] ||
10
+ claims[getConfig().auth0Config.staffIdClaim] ||
11
+ claims[getConfig().auth0Config.userIdClaim]
12
+ );
9
13
  })
10
14
  .catch((err) => {
11
15
  reject(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-aws",
3
- "version": "2.0.1-auth.2",
3
+ "version": "2.0.2-auth.0",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "scripts": {
6
6
  "betapatch": "npm version prepatch --preid=beta",