@everymatrix/general-player-login-form 0.0.317 → 0.0.320
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
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
<div class="webcomponent">
|
|
18
|
-
<general-player-login-form endpoint="https://demo-api.stage.norway.everymatrix.com/v1"></general-player-login-form>
|
|
18
|
+
<general-player-login-form endpoint="https://demo-api.stage.norway.everymatrix.com/v1" smsverification="true"></general-player-login-form>
|
|
19
19
|
</div>
|
|
20
20
|
|
|
21
21
|
</body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everymatrix/general-player-login-form",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.320",
|
|
4
4
|
"main": "dist/general-player-login-form.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": "
|
|
39
|
+
"gitHead": "94830a853e3e1b7a9268ddd59c3f4f4abfbbf7ea"
|
|
40
40
|
}
|
|
@@ -4,16 +4,26 @@
|
|
|
4
4
|
import { onMount } from "svelte";
|
|
5
5
|
import { isMobile } from 'rvhelper';
|
|
6
6
|
|
|
7
|
+
import '@everymatrix/general-player-sms-verification-form';
|
|
8
|
+
|
|
7
9
|
// Native bridge
|
|
8
10
|
import { isNative, call as callNative, registerEventListener as registerNativeEventListener } from 'js-native-bridge';
|
|
9
11
|
|
|
10
12
|
import { _, addNewMessages, setLocale, setupI18n } from './i18n';
|
|
11
13
|
import { LoginForm } from './translations';
|
|
12
14
|
|
|
15
|
+
export let endpoint;
|
|
13
16
|
export let imagedesktop:string = '';
|
|
14
17
|
export let captchakey:string = '';
|
|
15
18
|
export let lang:string = '';
|
|
16
|
-
|
|
19
|
+
export let smsverification = 'false';
|
|
20
|
+
|
|
21
|
+
let playerId;
|
|
22
|
+
let smsTokenId;
|
|
23
|
+
let startSmsValidation = false;
|
|
24
|
+
let smsTemplate: string = 'Please use this code {0} to activate your accout';
|
|
25
|
+
let smsSendApiFailed = false;
|
|
26
|
+
let number;
|
|
17
27
|
let mobileView:boolean = false;
|
|
18
28
|
let userAgent:string = window.navigator.userAgent;
|
|
19
29
|
let userValue:string = '';
|
|
@@ -144,10 +154,53 @@
|
|
|
144
154
|
errorMessage = e.data.error;
|
|
145
155
|
isLoading = false;
|
|
146
156
|
break;
|
|
157
|
+
|
|
158
|
+
case 'SmsVerification':
|
|
159
|
+
playerId = e.data.userid;
|
|
160
|
+
number = e.data.number;
|
|
161
|
+
startSmsValidation = e.data.startSmsValidation;
|
|
162
|
+
sendSmsToken(number, playerId);
|
|
163
|
+
break;
|
|
164
|
+
case 'SmsHasBeenValidated':
|
|
165
|
+
submitLoginForm();
|
|
166
|
+
break;
|
|
147
167
|
}
|
|
148
168
|
}
|
|
149
169
|
}
|
|
150
170
|
|
|
171
|
+
const sendSmsToken = async (number, playerId) => {
|
|
172
|
+
try {
|
|
173
|
+
const res = await fetch(`${endpoint}/player/sms/token`,{
|
|
174
|
+
method: 'POST',
|
|
175
|
+
headers: {
|
|
176
|
+
'Content-Type': 'application/json',
|
|
177
|
+
accept: 'application/json',
|
|
178
|
+
},
|
|
179
|
+
body: JSON.stringify(
|
|
180
|
+
{
|
|
181
|
+
userId: playerId,
|
|
182
|
+
messageTemplate: smsTemplate,
|
|
183
|
+
destination: number,
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const data = await res.json();
|
|
189
|
+
|
|
190
|
+
if(res.ok) {
|
|
191
|
+
smsTokenId = data.id;
|
|
192
|
+
let smsMaxValidations = data.maxValidationAttempts;
|
|
193
|
+
smsSendApiFailed = false;
|
|
194
|
+
} else {
|
|
195
|
+
smsSendApiFailed = true;
|
|
196
|
+
throw new Error("Failed to fetch");
|
|
197
|
+
}
|
|
198
|
+
} catch(err) {
|
|
199
|
+
smsSendApiFailed = true;
|
|
200
|
+
console.error(err);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
151
204
|
const initialLoad = ():void => {
|
|
152
205
|
setLocale(lang);
|
|
153
206
|
}
|
|
@@ -192,7 +245,7 @@
|
|
|
192
245
|
}
|
|
193
246
|
});
|
|
194
247
|
|
|
195
|
-
$: lang && initialLoad();
|
|
248
|
+
$: endpoint && lang && initialLoad();
|
|
196
249
|
</script>
|
|
197
250
|
|
|
198
251
|
<svelte:head>
|
|
@@ -210,41 +263,50 @@
|
|
|
210
263
|
{:else}
|
|
211
264
|
<div class="FormContainer {mobileView ? 'FormMobileContainer' : ''}" part="FormContainer {mobileView ? 'FormMobileContainer' : ''}">
|
|
212
265
|
<div class="FormLeftSide" part="FormLeftSide">
|
|
213
|
-
|
|
214
|
-
<
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
266
|
+
{#if startSmsValidation}
|
|
267
|
+
<general-player-sms-verification-form
|
|
268
|
+
{endpoint}
|
|
269
|
+
{number}
|
|
270
|
+
playerid={playerId}
|
|
271
|
+
tokenid={smsTokenId}>
|
|
272
|
+
</general-player-sms-verification-form>
|
|
219
273
|
{:else}
|
|
220
|
-
<div class="
|
|
221
|
-
<
|
|
222
|
-
|
|
223
|
-
<label for="username">{$_('loginForm.loginUsername')}:<span class="FormRequired" part="FormRequired">*</span></label>
|
|
224
|
-
<input bind:value={userValue} on:keyup={validateUserName} type="text" id="email" name="email" autocomplete="username email" required/>
|
|
225
|
-
{#if invalidName}
|
|
226
|
-
<p class="InvalidInput" part="InvalidInput">{$_('loginForm.loginUsernameError')}</p>
|
|
227
|
-
{/if}
|
|
228
|
-
</div>
|
|
229
|
-
<div class="PasswordContainer {invalidPassword ? 'InvalidField' : ''}" part="PasswordContainer {invalidPassword ? 'InvalidField' : ''}">
|
|
230
|
-
<label for="current-password">{$_('loginForm.loginPassword')}:<span class="FormRequired" part="FormRequired">*</span></label>
|
|
231
|
-
<input bind:value={userPassword} on:keyup={validatePassword} type="password" name="current-password" id="current-password" bind:this={passwordVisibilityToggle} autocomplete="current-password" aria-describedby="password-constraints" required/>
|
|
232
|
-
{#if isPasswordVisible}
|
|
233
|
-
<svg on:click={() => hidePassword()} class="TogglePasswordVisibility" part="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.844" height="12.887" viewBox="0 0 18.844 12.887"><defs><style>.a{fill:var(--emfe-w-color-contrast, #07072A);}</style></defs><g transform="translate(-110.856 -23.242)"><circle class="a" cx="0.05" cy="0.05" r="0.05" transform="translate(121.017 31.148)"/><g transform="translate(117.499 27.37)"><path class="a" d="M147.413,43.174a2.774,2.774,0,0,0-3.229-3.943Z" transform="translate(-142.164 -39.123)"/><path class="a" d="M137.031,43.1a2.778,2.778,0,0,0,3.447,4.209Z" transform="translate(-136.413 -42.068)"/></g><g transform="translate(110.856 24.899)"><path class="a" d="M122.538,42.061a7.043,7.043,0,0,1-2.325.53,10.373,10.373,0,0,1-4.393-1.482,36.509,36.509,0,0,1-3.873-2.391.13.13,0,0,1,0-.208,44.141,44.141,0,0,1,3.873-2.651c.394-.233.768-.437,1.13-.622l-.686-.838c-.322.167-.651.347-.99.55a37.989,37.989,0,0,0-3.977,2.729,1.21,1.21,0,0,0-.442.962,1.1,1.1,0,0,0,.494.936,34.416,34.416,0,0,0,3.977,2.469,11.468,11.468,0,0,0,4.886,1.611,8.427,8.427,0,0,0,3.039-.725Z" transform="translate(-110.856 -33.157)"/><path class="a" d="M149.119,34.14a45.875,45.875,0,0,0-4.055-2.729,20.541,20.541,0,0,0-2.547-1.248,5.6,5.6,0,0,0-4.79-.017l.7.856a5.254,5.254,0,0,1,1.672-.346,10.072,10.072,0,0,1,4.445,1.663,34.132,34.132,0,0,1,3.925,2.651.13.13,0,0,1,0,.208,40.2,40.2,0,0,1-3.925,2.391c-.179.092-.352.176-.525.26l.684.835c.1-.054.2-.1.309-.159a36.356,36.356,0,0,0,4.055-2.469,1.067,1.067,0,0,0,.52-.936A1.159,1.159,0,0,0,149.119,34.14Z" transform="translate(-130.743 -29.617)"/></g><rect class="a" width="0.972" height="15.861" rx="0.486" transform="translate(114.827 23.858) rotate(-39.315)"/></g></svg>
|
|
234
|
-
{:else}
|
|
235
|
-
<svg on:click={() => showPassword()} class="TogglePasswordVisibility" part="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.843" height="10.5" viewBox="0 0 18.843 10.5"><defs><style>.a{fill:var(--emfe-w-color-contrast, #07072A);}</style></defs><g transform="translate(-14.185 -27.832)"><path class="a" d="M23.541,38.332a11.467,11.467,0,0,1-4.886-1.611,34.413,34.413,0,0,1-3.976-2.469,1.1,1.1,0,0,1-.494-.936,1.21,1.21,0,0,1,.442-.962A37.986,37.986,0,0,1,18.6,29.625a16.06,16.06,0,0,1,2.521-1.248,6.862,6.862,0,0,1,2.417-.546,6.862,6.862,0,0,1,2.417.546,20.541,20.541,0,0,1,2.547,1.248,45.872,45.872,0,0,1,4.054,2.729,1.159,1.159,0,0,1,.468.962,1.067,1.067,0,0,1-.52.936,36.353,36.353,0,0,1-4.054,2.469A11.2,11.2,0,0,1,23.541,38.332Zm0-9.46a9.813,9.813,0,0,0-4.392,1.663,44.138,44.138,0,0,0-3.873,2.651.13.13,0,0,0,0,.208,36.5,36.5,0,0,0,3.873,2.391,10.372,10.372,0,0,0,4.392,1.481,11.051,11.051,0,0,0,4.444-1.481,40.2,40.2,0,0,0,3.925-2.391.13.13,0,0,0,0-.208h0a34.132,34.132,0,0,0-3.925-2.651A10.072,10.072,0,0,0,23.541,28.872Z" transform="translate(0)"/><circle class="a" cx="2.779" cy="2.779" r="2.779" transform="translate(20.827 30.303)"/></g></svg>
|
|
236
|
-
{/if}
|
|
237
|
-
{#if invalidPassword}
|
|
238
|
-
<p class="InvalidInput" part="InvalidInput">{$_('loginForm.loginPasswordError')}</p>
|
|
239
|
-
{/if}
|
|
240
|
-
</div>
|
|
241
|
-
{#if errorMessage}
|
|
242
|
-
<p class="ErrorMessage" part="ErrorMessage">{errorMessage}</p>
|
|
243
|
-
{/if}
|
|
244
|
-
</form>
|
|
245
|
-
<button class="SignInButton" part="SignInButton" on:click={() => submitLoginForm()} disabled={isFormDataInvalid} id="signin-button">{$_('loginForm.loginButton')}</button>
|
|
246
|
-
<button class="ForgotPasswordButton" part="ForgotPasswordButton" on:click={() => switchToForgotPassword()}>{$_('loginForm.loginForgotPassword')}</button>
|
|
274
|
+
<div class="FormHeader" part="FormHeader">
|
|
275
|
+
<h4 class="FormHeaderTitle" part="FormHeaderTitle">{$_('loginForm.loginTitle')}</h4>
|
|
276
|
+
<p class="FormHeaderSubtitle" part="FormHeaderSubtitle">{$_('loginForm.loginSubtitle')} <span class="FormRegisterCallToAction" on:click={() => switchToRegister()}>{$_('loginForm.loginSubtitleRegister')}</span></p>
|
|
247
277
|
</div>
|
|
278
|
+
{#if waitingForCredentials}
|
|
279
|
+
<p>Waiting for credentials</p>
|
|
280
|
+
{:else}
|
|
281
|
+
<div class="FormContent" part="FormContent">
|
|
282
|
+
<form id="signin" >
|
|
283
|
+
<div class="UserContainer {invalidName ? 'InvalidField' : ''}" part="UserContainer {invalidName ? 'InvalidField' : ''}">
|
|
284
|
+
<label for="username">{$_('loginForm.loginUsername')}:<span class="FormRequired" part="FormRequired">*</span></label>
|
|
285
|
+
<input bind:value={userValue} on:keyup={validateUserName} type="text" id="email" name="email" autocomplete="username email" required/>
|
|
286
|
+
{#if invalidName}
|
|
287
|
+
<p class="InvalidInput" part="InvalidInput">{$_('loginForm.loginUsernameError')}</p>
|
|
288
|
+
{/if}
|
|
289
|
+
</div>
|
|
290
|
+
<div class="PasswordContainer {invalidPassword ? 'InvalidField' : ''}" part="PasswordContainer {invalidPassword ? 'InvalidField' : ''}">
|
|
291
|
+
<label for="current-password">{$_('loginForm.loginPassword')}:<span class="FormRequired" part="FormRequired">*</span></label>
|
|
292
|
+
<input bind:value={userPassword} on:keyup={validatePassword} type="password" name="current-password" id="current-password" bind:this={passwordVisibilityToggle} autocomplete="current-password" aria-describedby="password-constraints" required/>
|
|
293
|
+
{#if isPasswordVisible}
|
|
294
|
+
<svg on:click={() => hidePassword()} class="TogglePasswordVisibility" part="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.844" height="12.887" viewBox="0 0 18.844 12.887"><defs><style>.a{fill:var(--emfe-w-color-contrast, #07072A);}</style></defs><g transform="translate(-110.856 -23.242)"><circle class="a" cx="0.05" cy="0.05" r="0.05" transform="translate(121.017 31.148)"/><g transform="translate(117.499 27.37)"><path class="a" d="M147.413,43.174a2.774,2.774,0,0,0-3.229-3.943Z" transform="translate(-142.164 -39.123)"/><path class="a" d="M137.031,43.1a2.778,2.778,0,0,0,3.447,4.209Z" transform="translate(-136.413 -42.068)"/></g><g transform="translate(110.856 24.899)"><path class="a" d="M122.538,42.061a7.043,7.043,0,0,1-2.325.53,10.373,10.373,0,0,1-4.393-1.482,36.509,36.509,0,0,1-3.873-2.391.13.13,0,0,1,0-.208,44.141,44.141,0,0,1,3.873-2.651c.394-.233.768-.437,1.13-.622l-.686-.838c-.322.167-.651.347-.99.55a37.989,37.989,0,0,0-3.977,2.729,1.21,1.21,0,0,0-.442.962,1.1,1.1,0,0,0,.494.936,34.416,34.416,0,0,0,3.977,2.469,11.468,11.468,0,0,0,4.886,1.611,8.427,8.427,0,0,0,3.039-.725Z" transform="translate(-110.856 -33.157)"/><path class="a" d="M149.119,34.14a45.875,45.875,0,0,0-4.055-2.729,20.541,20.541,0,0,0-2.547-1.248,5.6,5.6,0,0,0-4.79-.017l.7.856a5.254,5.254,0,0,1,1.672-.346,10.072,10.072,0,0,1,4.445,1.663,34.132,34.132,0,0,1,3.925,2.651.13.13,0,0,1,0,.208,40.2,40.2,0,0,1-3.925,2.391c-.179.092-.352.176-.525.26l.684.835c.1-.054.2-.1.309-.159a36.356,36.356,0,0,0,4.055-2.469,1.067,1.067,0,0,0,.52-.936A1.159,1.159,0,0,0,149.119,34.14Z" transform="translate(-130.743 -29.617)"/></g><rect class="a" width="0.972" height="15.861" rx="0.486" transform="translate(114.827 23.858) rotate(-39.315)"/></g></svg>
|
|
295
|
+
{:else}
|
|
296
|
+
<svg on:click={() => showPassword()} class="TogglePasswordVisibility" part="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.843" height="10.5" viewBox="0 0 18.843 10.5"><defs><style>.a{fill:var(--emfe-w-color-contrast, #07072A);}</style></defs><g transform="translate(-14.185 -27.832)"><path class="a" d="M23.541,38.332a11.467,11.467,0,0,1-4.886-1.611,34.413,34.413,0,0,1-3.976-2.469,1.1,1.1,0,0,1-.494-.936,1.21,1.21,0,0,1,.442-.962A37.986,37.986,0,0,1,18.6,29.625a16.06,16.06,0,0,1,2.521-1.248,6.862,6.862,0,0,1,2.417-.546,6.862,6.862,0,0,1,2.417.546,20.541,20.541,0,0,1,2.547,1.248,45.872,45.872,0,0,1,4.054,2.729,1.159,1.159,0,0,1,.468.962,1.067,1.067,0,0,1-.52.936,36.353,36.353,0,0,1-4.054,2.469A11.2,11.2,0,0,1,23.541,38.332Zm0-9.46a9.813,9.813,0,0,0-4.392,1.663,44.138,44.138,0,0,0-3.873,2.651.13.13,0,0,0,0,.208,36.5,36.5,0,0,0,3.873,2.391,10.372,10.372,0,0,0,4.392,1.481,11.051,11.051,0,0,0,4.444-1.481,40.2,40.2,0,0,0,3.925-2.391.13.13,0,0,0,0-.208h0a34.132,34.132,0,0,0-3.925-2.651A10.072,10.072,0,0,0,23.541,28.872Z" transform="translate(0)"/><circle class="a" cx="2.779" cy="2.779" r="2.779" transform="translate(20.827 30.303)"/></g></svg>
|
|
297
|
+
{/if}
|
|
298
|
+
{#if invalidPassword}
|
|
299
|
+
<p class="InvalidInput" part="InvalidInput">{$_('loginForm.loginPasswordError')}</p>
|
|
300
|
+
{/if}
|
|
301
|
+
</div>
|
|
302
|
+
{#if errorMessage}
|
|
303
|
+
<p class="ErrorMessage" part="ErrorMessage">{errorMessage}</p>
|
|
304
|
+
{/if}
|
|
305
|
+
</form>
|
|
306
|
+
<button class="SignInButton" part="SignInButton" on:click={() => submitLoginForm()} disabled={isFormDataInvalid} id="signin-button">{$_('loginForm.loginButton')}</button>
|
|
307
|
+
<button class="ForgotPasswordButton" part="ForgotPasswordButton" on:click={() => switchToForgotPassword()}>{$_('loginForm.loginForgotPassword')}</button>
|
|
308
|
+
</div>
|
|
309
|
+
{/if}
|
|
248
310
|
{/if}
|
|
249
311
|
</div>
|
|
250
312
|
{#if !mobileView}
|