@everymatrix/general-player-login-form 0.0.205 → 0.0.209
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everymatrix/general-player-login-form",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.209",
|
|
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": "0cdc5a5de8fee8ead3a559d272a436d01db74a1c"
|
|
40
40
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { isMobile } from 'rvhelper';
|
|
6
6
|
|
|
7
7
|
export let imagedesktop:string = '';
|
|
8
|
+
export let captchakey:string = '';
|
|
8
9
|
|
|
9
10
|
let mobileView:boolean = false;
|
|
10
11
|
let userAgent:string = window.navigator.userAgent;
|
|
@@ -24,62 +25,65 @@
|
|
|
24
25
|
let isPasswordVisible:boolean = false;
|
|
25
26
|
let isFormDataInvalid:boolean = true;
|
|
26
27
|
|
|
27
|
-
const captchaKey = '6Lc7w8YcAAAAAEMHc_VNN9bqfVnILoUOHSHyZ0yn';
|
|
28
|
-
|
|
29
28
|
const regexValidators = {
|
|
30
29
|
user: /^(?!(?:.*\d){9})(?=(?:.*[a-zA-Z]){2})^[a-zA-Z\d]*$/,
|
|
31
30
|
email: /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,
|
|
32
31
|
password: /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{8,20}$/
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
const doRecaptcha = () => {
|
|
34
|
+
const doRecaptcha = ():Promise<string> => {
|
|
36
35
|
return new Promise((resolve, reject) => {
|
|
36
|
+
// @ts-ignore
|
|
37
37
|
grecaptcha.ready(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
grecaptcha.execute(captchakey, { action: "submit" })
|
|
40
|
+
.then((token:string) => {
|
|
41
|
+
resolve(token);
|
|
42
|
+
});
|
|
41
43
|
});
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
const showPassword = () => {
|
|
47
|
+
const showPassword = ():void => {
|
|
46
48
|
isPasswordVisible = true;
|
|
47
49
|
togglePasswordVisibility();
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
const hidePassword = () => {
|
|
52
|
+
const hidePassword = ():void => {
|
|
51
53
|
isPasswordVisible = false;
|
|
52
54
|
togglePasswordVisibility();
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
const togglePasswordVisibility = () => {
|
|
57
|
+
const togglePasswordVisibility = ():void => {
|
|
58
|
+
// @ts-ignore
|
|
56
59
|
passwordVisibilityToggle.type = isPasswordVisible ? "text" : "password";
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
const switchToRegister = () => {
|
|
62
|
+
const switchToRegister = ():void => {
|
|
60
63
|
window.postMessage({ type: "ToRegister" }, window.location.href);
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
const switchToForgotPassword = () => {
|
|
66
|
+
const switchToForgotPassword = ():void => {
|
|
64
67
|
window.postMessage({ type: "NavForgotPassword" }, window.location.href);
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
const submitLoginForm = () => {
|
|
68
|
-
doRecaptcha()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
const submitLoginForm = ():void => {
|
|
71
|
+
doRecaptcha()
|
|
72
|
+
.then((token:string) => {
|
|
73
|
+
if (checkUserIdentifier(userValue) && checkUserPassword(userPassword)) {
|
|
74
|
+
loginFormData = {
|
|
75
|
+
username: userValue,
|
|
76
|
+
password: userPassword,
|
|
77
|
+
token: token
|
|
78
|
+
};
|
|
79
|
+
isLoading = true;
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
window.postMessage({ type: "SubmitLoginForm", loginData: loginFormData }, window.location.href);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
80
84
|
}
|
|
81
85
|
|
|
82
|
-
const checkUserIdentifier = (user:string) => {
|
|
86
|
+
const checkUserIdentifier = (user:string):boolean => {
|
|
83
87
|
if (regexValidators.user.test(user) || regexValidators.email.test(user)) {
|
|
84
88
|
return true;
|
|
85
89
|
} else {
|
|
@@ -87,7 +91,7 @@
|
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
|
|
90
|
-
const checkUserPassword = (password:string) => {
|
|
94
|
+
const checkUserPassword = (password:string):boolean => {
|
|
91
95
|
if (regexValidators.password.test(password)) {
|
|
92
96
|
return true;
|
|
93
97
|
} else {
|
|
@@ -95,36 +99,31 @@
|
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
101
|
|
|
98
|
-
const validateUserName = () => {
|
|
102
|
+
const validateUserName = ():void => {
|
|
99
103
|
invalidName = !checkUserIdentifier(userValue);
|
|
100
104
|
isFormDataInvalid = (!invalidName && !invalidPassword && userPassword) ? false : true;
|
|
101
105
|
}
|
|
102
106
|
|
|
103
|
-
const validatePassword = () => {
|
|
107
|
+
const validatePassword = ():void => {
|
|
104
108
|
invalidPassword = !checkUserPassword(userPassword);
|
|
105
109
|
isFormDataInvalid = (!invalidName && !invalidPassword && userValue) ? false : true;
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
const messageHandler = (e:
|
|
112
|
+
const messageHandler = (e:MessageEvent):void => {
|
|
109
113
|
if (e.data) {
|
|
110
|
-
switch(e.data.type) {
|
|
111
|
-
|
|
114
|
+
switch (e.data.type) {
|
|
112
115
|
case 'ModalLoader':
|
|
113
116
|
isLoading = false;
|
|
114
|
-
|
|
117
|
+
break;
|
|
115
118
|
|
|
116
119
|
case 'UserSessionID':
|
|
117
120
|
isLoading = false;
|
|
118
|
-
|
|
121
|
+
break;
|
|
119
122
|
|
|
120
123
|
case 'HasError':
|
|
121
124
|
errorMessage = e.data.error;
|
|
122
125
|
isLoading = false;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
default:
|
|
126
|
-
// do nothing
|
|
127
|
-
break;
|
|
126
|
+
break;
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
}
|
|
@@ -133,9 +132,7 @@
|
|
|
133
132
|
window.addEventListener('message', messageHandler, false);
|
|
134
133
|
window.postMessage({ type: "LoginRegisterModalActive" }, window.location.href);
|
|
135
134
|
|
|
136
|
-
|
|
137
|
-
mobileView = true;
|
|
138
|
-
}
|
|
135
|
+
mobileView = isMobile(userAgent);
|
|
139
136
|
|
|
140
137
|
return () => {
|
|
141
138
|
window.removeEventListener('message', messageHandler);
|
|
@@ -144,10 +141,13 @@
|
|
|
144
141
|
</script>
|
|
145
142
|
|
|
146
143
|
<svelte:head>
|
|
147
|
-
|
|
144
|
+
{#if captchakey}
|
|
145
|
+
<script src="//www.google.com/recaptcha/api.js?render={captchakey}" async defer></script>
|
|
146
|
+
{/if}
|
|
148
147
|
</svelte:head>
|
|
149
148
|
|
|
150
|
-
<div class="g-recaptcha" data-sitekey="{
|
|
149
|
+
<div class="g-recaptcha" data-sitekey="{captchakey}" />
|
|
150
|
+
|
|
151
151
|
{#if isLoading}
|
|
152
152
|
<div class="ModalLoader"></div>
|
|
153
153
|
{:else}
|