@everymatrix/player-account-controller 0.0.166 → 0.0.170

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/index.html CHANGED
@@ -33,8 +33,8 @@
33
33
  <player-account-controller
34
34
  endpoint="https://demo-api.stage.norway.everymatrix.com/v1"
35
35
  cmsendpoint="https://wp-one-widgets.everymatrix.com/wp-json/wpone-rest/v1"
36
- playerid="3685503"
37
- session="32d59c64-3678-4635-96c1-ce220b8fbf3a"
36
+ playerid="3903441"
37
+ session="c41c6f46-d337-4a93-966b-f4924e6cd177"
38
38
  accountpath="/menu-locations/profile-menu"
39
39
  notificationpath="/support_information"
40
40
  customnotifications="#58586B,#2687F6,#D0046C"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/player-account-controller",
3
- "version": "0.0.166",
3
+ "version": "0.0.170",
4
4
  "main": "dist/player-account-controller.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -29,8 +29,8 @@
29
29
  "typescript": "^3.9.3"
30
30
  },
31
31
  "dependencies": {
32
- "@everymatrix/player-account-menu": "^0.0.166",
33
- "@everymatrix/player-account-notifications": "^0.0.166",
32
+ "@everymatrix/player-account-menu": "^0.0.170",
33
+ "@everymatrix/player-account-notifications": "^0.0.170",
34
34
  "cross-env": "^7.0.3",
35
35
  "sirv-cli": "^1.0.0",
36
36
  "svelte": "^3.0.0"
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "cc5cea8f5d4ed68bf0b052d98cc82ce69e97fc45"
41
+ "gitHead": "3836860c7d1128dcea8bc1638c7912ee0f50ce6b"
42
42
  }
@@ -54,21 +54,22 @@
54
54
  let showdeletenotification:boolean = false;
55
55
  let realityCheckData:any;
56
56
  let storedRealityCheck:string = '';
57
+ let errorPasswordChanged:string = '';
58
+ let showErrorPasswordChanged:boolean = false;
57
59
 
58
-
59
- const widgetTitle = ['Profile Info',
60
+ const widgetTitle = ['Profile Info',
60
61
  'Change password',
61
- 'Reality Check',
62
- 'Timeout',
63
- 'Account Closure',
64
- 'Gaming Limits',
65
- 'Self Exclusion',
66
- 'Active Bonuses',
67
- 'Bonus History',
68
- 'Gaming History',
69
- 'Deposit',
70
- 'Withdrawal',
71
- 'Pending Withdrawals',
62
+ 'Reality Check',
63
+ 'Timeout',
64
+ 'Account Closure',
65
+ 'Gaming Limits',
66
+ 'Self Exclusion',
67
+ 'Active Bonuses',
68
+ 'Bonus History',
69
+ 'Gaming History',
70
+ 'Deposit',
71
+ 'Withdrawal',
72
+ 'Pending Withdrawals',
72
73
  'Transaction History'];
73
74
  const accountMenuEndpointURL:string = cmsendpoint + accountpath;
74
75
  const notificationsEndpointURL:string = cmsendpoint + notificationpath;
@@ -129,31 +130,7 @@
129
130
  break;
130
131
 
131
132
  case 'ChangePassword':
132
- let playerCurrentPassword = e.data.userCurrentPassword;
133
- let playerNewPassword = e.data.userNewPassword;
134
-
135
- let data = {
136
- currentPassword: playerCurrentPassword,
137
- newPassword: playerNewPassword
138
- };
139
- let optionsChangePassword = {
140
- method: "POST",
141
- headers: {
142
- 'X-SessionID': sessionId,
143
- 'Content-Type': "application/json",
144
- 'Accept': 'application/json',
145
- },
146
- body: JSON.stringify(data)
147
- };
148
-
149
- fetch(`${endpoint}/player/${userId}/password`, optionsChangePassword)
150
- .then((res:any) => {
151
- if (res.status == 200) {
152
- window.postMessage({ type: 'PasswordChangedSuccessfully' }, window.location.href);
153
- } else {
154
- // ERROR
155
- }
156
- });
133
+ sendChangePassword(e.data.userCurrentPassword, e.data.userNewPassword);
157
134
 
158
135
  break;
159
136
 
@@ -400,6 +377,34 @@
400
377
  });
401
378
  }
402
379
 
380
+ const sendChangePassword = async (playerCurrentPassword:string, playerNewPassword:string) => {
381
+ let data = {
382
+ currentPassword: playerCurrentPassword,
383
+ newPassword: playerNewPassword
384
+ };
385
+ let optionsChangePassword = {
386
+ method: "POST",
387
+ headers: {
388
+ 'X-SessionID': sessionId,
389
+ 'Content-Type': "application/json",
390
+ 'Accept': 'application/json',
391
+ },
392
+ body: JSON.stringify(data)
393
+ };
394
+
395
+ let response:any = await fetch(`${endpoint}/player/${userId}/password`, optionsChangePassword);
396
+ let dataResponse:any = await response.json();
397
+
398
+ if (response.ok) {
399
+ window.postMessage({ type: 'PasswordChangedSuccessfully' }, window.location.href);
400
+ } else {
401
+ // Parsing GMCore message 'cuz it's stupid and it doesn't know how to send error messages in 2021 ffs
402
+ errorPasswordChanged = dataResponse.error.substring(dataResponse.error.indexOf('errorMessage') + 13, dataResponse.error.length);
403
+ showErrorPasswordChanged = true;
404
+ window.postMessage({ type: "ShowPasswordChangedError", showErrorPasswordChanged, errorPasswordChanged }, window.location.href);
405
+ }
406
+ }
407
+
403
408
  const getRealityCheckData = (url:string) => {
404
409
  let options = {
405
410
  method: 'GET',