@everymatrix/general-player-login-form 0.0.118 → 0.0.122

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
@@ -30,8 +30,8 @@
30
30
  </header>
31
31
 
32
32
  <div class="webcomponent">
33
- <general-player-login-form></general-player-login-form>
33
+ <general-player-login-form endpoint="https://demo-api.stage.norway.everymatrix.com/v1"></general-player-login-form>
34
34
  </div>
35
-
35
+
36
36
  </body>
37
37
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/general-player-login-form",
3
- "version": "0.0.118",
3
+ "version": "0.0.122",
4
4
  "main": "index.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "2b3a5975cb7b7356688a245141561f45cc075eaa"
39
+ "gitHead": "974bc1c7b1767d96828ec1b85d35e27a622c9a63"
40
40
  }
@@ -14,27 +14,32 @@
14
14
  }
15
15
  let invalidName:boolean = false;
16
16
  let invalidPassword:boolean = false;
17
+
18
+ let errorMessage:string = '';
19
+
20
+ const captchaKey = '6Lc7w8YcAAAAAEMHc_VNN9bqfVnILoUOHSHyZ0yn';
21
+
17
22
  const regexValidators = {
18
23
  user: /^(?!(?:.*\d){9})(?=(?:.*[a-zA-Z]){2})^[a-zA-Z\d]*$/,
19
24
  email: /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]{2,3}$/,
20
25
  password: /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{8,20}$/
21
26
  }
22
27
 
23
- let captcha;
24
- let Recaptcha;
25
- let errorMessage:string = '';
26
-
27
- const onloadCallback = () => {
28
- window.grecaptcha.render(Recaptcha, {
29
- 'sitekey' : '6Lej4KgUAAAAAPcsWUuf7xJ1N002JecrLXyC_U56'
28
+ const doRecaptcha = () => {
29
+ return new Promise((resolve, reject) => {
30
+ grecaptcha.ready(() => {
31
+ grecaptcha.execute(captchaKey, { action: "submit" }).then((token) => {
32
+ resolve(token);
33
+ });
34
+ });
30
35
  });
31
36
  }
32
37
 
33
38
  onMount(async () => {
34
- window.onloadCallback = onloadCallback;
35
39
  window.addEventListener('message', messageHandler, false);
36
40
  window.postMessage({ type: "LoginRegisterModalActive" }, window.location.href);
37
- if(isMobile(userAgent)) {
41
+
42
+ if (isMobile(userAgent)) {
38
43
  mobileView = true;
39
44
  }
40
45
 
@@ -95,17 +100,21 @@
95
100
 
96
101
  const submitLoginForm = () => {
97
102
  isLoading = true;
98
- if(checkUserIdentifier(userValue) && checkUserPassword(userPassword)) {
99
- loginFormData = {
100
- username: userValue,
101
- password: userPassword
103
+ doRecaptcha().then((token) => {
104
+ if (checkUserIdentifier(userValue) && checkUserPassword(userPassword)) {
105
+ loginFormData = {
106
+ username: userValue,
107
+ password: userPassword,
108
+ token: token
109
+ };
110
+
111
+ window.postMessage({ type: "SubmitLoginForm", loginData: loginFormData }, window.location.href);
102
112
  }
103
- window.postMessage({ type: "SubmitLoginForm", loginData: loginFormData }, window.location.href);
104
- }
113
+ });
105
114
  }
106
115
 
107
116
  const checkUserIdentifier = (user:string) => {
108
- if(regexValidators.user.test(user) || regexValidators.email.test(user)) {
117
+ if (regexValidators.user.test(user) || regexValidators.email.test(user)) {
109
118
  return true;
110
119
  } else {
111
120
  return false;
@@ -113,7 +122,7 @@
113
122
  }
114
123
 
115
124
  const checkUserPassword = (password:string) => {
116
- if(regexValidators.password.test(password)) {
125
+ if (regexValidators.password.test(password)) {
117
126
  return true;
118
127
  } else {
119
128
  return false;
@@ -130,13 +139,13 @@
130
139
  </script>
131
140
 
132
141
  <svelte:head>
133
- <script src="//www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"></script>
142
+ <script src="//www.google.com/recaptcha/api.js?render={captchaKey}" async defer></script>
134
143
  </svelte:head>
135
144
 
145
+ <div class="g-recaptcha" data-sitekey="{captchaKey}" />
136
146
  {#if isLoading}
137
147
  <div class="ModalLoader"></div>
138
148
  {:else}
139
-
140
149
  <div class="FormContainer {mobileView ? 'FormMobileContainer' : ''}">
141
150
  <div class="FormLeftSide">
142
151
  <div class="FormHeader">
@@ -163,9 +172,6 @@
163
172
  <p class="InvalidInput">Password must be 8-20 characters long, and contain at least 1 uppercase letter, 1 number and 1 special character.</p>
164
173
  {/if}
165
174
  </div>
166
- <div class="CaptchaContainer">
167
- <div bind:this={Recaptcha} id="Recaptcha" class="g-recaptcha"></div>
168
- </div>
169
175
  {#if errorMessage}
170
176
  <p class="ErrorMessage">{errorMessage}</p>
171
177
  {/if}