@cocreate/users 1.22.26 → 1.23.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.
- package/CHANGELOG.md +25 -0
- package/CoCreate.config.js +2 -2
- package/demo/signin.html +10 -12
- package/demo/signout.html +4 -4
- package/demo/signup.html +14 -18
- package/docs/index.html +28 -28
- package/package.json +8 -9
- package/src/client.js +62 -57
- package/src/server.js +27 -21
- package/webpack.config.js +79 -73
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
# [1.23.0](https://github.com/CoCreate-app/CoCreate-users/compare/v1.22.27...v1.23.0) (2023-08-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Change import statements in client.js to use capitalized class names. ([912011b](https://github.com/CoCreate-app/CoCreate-users/commit/912011be5302265af056d775bb5ddd798cb35221))
|
|
7
|
+
* crud attributes renamed ([4be4f0c](https://github.com/CoCreate-app/CoCreate-users/commit/4be4f0cdee84f12e04ba91d2ecfb168c4329bfb0))
|
|
8
|
+
* replace -target -selector ([9cfb2cb](https://github.com/CoCreate-app/CoCreate-users/commit/9cfb2cb22d1814eb8ebf7cc74bcd8b045a917269))
|
|
9
|
+
* updated actions callback data object ([3dd8ed2](https://github.com/CoCreate-app/CoCreate-users/commit/3dd8ed22c595353153362fd9732249ae6f19c2b7))
|
|
10
|
+
* webpack.config and package.json make use of mode=production instead of process.env ([cdf28d5](https://github.com/CoCreate-app/CoCreate-users/commit/cdf28d573c597b7692b1549d47fc676ffefba6a3))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* name attribute and variable renamed to key ([efbf453](https://github.com/CoCreate-app/CoCreate-users/commit/efbf45327b4c9654951f8d947bdd8d655ed8074d))
|
|
16
|
+
* Update package.json and replace "@cocreate/form" with "@cocreate/elements". ([ec00092](https://github.com/CoCreate-app/CoCreate-users/commit/ec0009228942a5ab10cc74d8152ac89afc62b9dc))
|
|
17
|
+
* update template_id to render-selector attribute. update filter attributes to filter selector-attributes ([c782cf7](https://github.com/CoCreate-app/CoCreate-users/commit/c782cf7941f951dcebb89f44457e2fdbb10a6c17))
|
|
18
|
+
|
|
19
|
+
## [1.22.27](https://github.com/CoCreate-app/CoCreate-users/compare/v1.22.26...v1.22.27) (2023-06-14)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* Update dependencies versions for [@cocreate](https://github.com/cocreate) libraries ([4253ced](https://github.com/CoCreate-app/CoCreate-users/commit/4253ced4d3e6849ac335a459c9557570bca4e1d9))
|
|
25
|
+
|
|
1
26
|
## [1.22.26](https://github.com/CoCreate-app/CoCreate-users/compare/v1.22.25...v1.22.26) (2023-06-11)
|
|
2
27
|
|
|
3
28
|
|
package/CoCreate.config.js
CHANGED
package/demo/signin.html
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
<link
|
|
12
12
|
rel="stylesheet"
|
|
13
13
|
href="../index.css"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
array="files"
|
|
15
|
+
object="637bc8fe91249e639db315d9"
|
|
16
|
+
key="src"
|
|
17
17
|
type="text/css" />
|
|
18
18
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
19
19
|
</head>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
class="justify-content:center align-items:center overflow:auto display:flex flex-wrap:wrap position:absolute width:100% height:100%">
|
|
36
36
|
<div
|
|
37
37
|
class="flex-grow:1 min-width:300px max-width:400px margin:15px">
|
|
38
|
-
<form realtime="false"
|
|
38
|
+
<form realtime="false" array="users" id="signin">
|
|
39
39
|
<div
|
|
40
40
|
class="overflow:hidden padding:0px_25px background:white">
|
|
41
41
|
<div class="float:left width:75% padding-top:25px">
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
<floating-label>
|
|
54
54
|
<input
|
|
55
55
|
type="email"
|
|
56
|
-
|
|
56
|
+
key="email"
|
|
57
57
|
placeholder="Email"
|
|
58
58
|
class="floating-label" />
|
|
59
59
|
</floating-label>
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
<floating-label>
|
|
62
62
|
<input
|
|
63
63
|
type="password"
|
|
64
|
-
|
|
64
|
+
key="password"
|
|
65
65
|
placeholder="Password"
|
|
66
66
|
class="floating-label" />
|
|
67
67
|
</floating-label>
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
</div>
|
|
78
78
|
</form>
|
|
79
79
|
|
|
80
|
-
<form
|
|
80
|
+
<form array="users" hidden id="forgotpass">
|
|
81
81
|
<div
|
|
82
82
|
class="overflow:hidden padding:0px_25px background:white">
|
|
83
83
|
<div class="float:left width:75% padding-top:25px">
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
<floating-label>
|
|
96
96
|
<input
|
|
97
97
|
type="email"
|
|
98
|
-
|
|
98
|
+
key="email"
|
|
99
99
|
id="email"
|
|
100
100
|
placeholder="Email"
|
|
101
101
|
class="floating-label" />
|
|
@@ -112,15 +112,13 @@
|
|
|
112
112
|
</div>
|
|
113
113
|
|
|
114
114
|
<div class="position:fixed!important bottom:15px right:15px">
|
|
115
|
-
<div
|
|
116
|
-
template="signIn"
|
|
117
|
-
class="card margin:5px padding:10px {{status}}">
|
|
115
|
+
<div template class="card margin:5px padding:10px {{status}}">
|
|
118
116
|
<span class="{{type}}">{{message}}</span
|
|
119
117
|
><a actions="removeElement"> X</a>
|
|
120
118
|
</div>
|
|
121
119
|
|
|
122
120
|
<div
|
|
123
|
-
template
|
|
121
|
+
template
|
|
124
122
|
class="card position:fixed!important bottom:15px right:15px padding:10px {{status}}">
|
|
125
123
|
<span class="{{type}}">{{message}}</span
|
|
126
124
|
><a actions="removeElement"> X</a>
|
package/demo/signout.html
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
<link
|
|
12
12
|
rel="stylesheet"
|
|
13
13
|
href="../index.css"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
array="files"
|
|
15
|
+
object="637bc8fe91249e639db315d9"
|
|
16
|
+
key="src"
|
|
17
17
|
type="text/css" />
|
|
18
18
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
19
19
|
</head>
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
|
|
50
50
|
<div class="position:fixed!important bottom:15px right:15px">
|
|
51
51
|
<div
|
|
52
|
-
template
|
|
52
|
+
template
|
|
53
53
|
class="card position:fixed!important bottom:15px right:15px padding:10px {{status}}">
|
|
54
54
|
<span class="{{type}}">{{message}}</span
|
|
55
55
|
><a actions="removeElement"> X</a>
|
package/demo/signup.html
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
<link
|
|
14
14
|
rel="stylesheet"
|
|
15
15
|
href="../index.css"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
array="files"
|
|
17
|
+
object="637bc8fe91249e639db315d9"
|
|
18
|
+
key="src"
|
|
19
19
|
type="text/css" />
|
|
20
20
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
21
21
|
</head>
|
|
@@ -78,9 +78,9 @@
|
|
|
78
78
|
<input
|
|
79
79
|
type="text"
|
|
80
80
|
id="name"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
array="users"
|
|
82
|
+
object=""
|
|
83
|
+
key="name"
|
|
84
84
|
placeholder="Full Name"
|
|
85
85
|
class="floating-label"
|
|
86
86
|
autocomplete="off"
|
|
@@ -90,10 +90,10 @@
|
|
|
90
90
|
<input
|
|
91
91
|
type="email"
|
|
92
92
|
id="email"
|
|
93
|
-
|
|
93
|
+
array="users"
|
|
94
94
|
unique
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
object=""
|
|
96
|
+
key="email"
|
|
97
97
|
placeholder="Email"
|
|
98
98
|
class="floating-label"
|
|
99
99
|
required />
|
|
@@ -104,9 +104,9 @@
|
|
|
104
104
|
<input
|
|
105
105
|
type="password"
|
|
106
106
|
id="password"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
array="users"
|
|
108
|
+
object=""
|
|
109
|
+
key="password"
|
|
110
110
|
placeholder="Password"
|
|
111
111
|
class="floating-label" />
|
|
112
112
|
</floating-label>
|
|
@@ -141,16 +141,12 @@
|
|
|
141
141
|
</main>
|
|
142
142
|
|
|
143
143
|
<div class="position:fixed!important bottom:15px right:15px">
|
|
144
|
-
<div
|
|
145
|
-
template="validate"
|
|
146
|
-
class="card margin:5px padding:10px {{status}}">
|
|
144
|
+
<div template class="card margin:5px padding:10px {{status}}">
|
|
147
145
|
<span class="{{type}}">{{message}}</span
|
|
148
146
|
><a actions="removeElement"> X</a>
|
|
149
147
|
</div>
|
|
150
148
|
|
|
151
|
-
<div
|
|
152
|
-
template="notification"
|
|
153
|
-
class="card margin:5px padding:10px {{status}}">
|
|
149
|
+
<div template class="card margin:5px padding:10px {{status}}">
|
|
154
150
|
<span class="{{type}}">{{message}}</span
|
|
155
151
|
><a actions="removeElement"> X</a>
|
|
156
152
|
</div>
|
package/docs/index.html
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
sizes="32x32"
|
|
12
12
|
href="https://cocreate.app/images/favicon.ico" />
|
|
13
13
|
<meta
|
|
14
|
-
|
|
14
|
+
key="description"
|
|
15
15
|
content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable." />
|
|
16
16
|
<meta
|
|
17
|
-
|
|
17
|
+
key="keywords"
|
|
18
18
|
content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
19
19
|
<meta name="robots" content="index,follow" />
|
|
20
20
|
<meta
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
<link
|
|
30
30
|
rel="stylesheet"
|
|
31
31
|
href="/docs/index.css"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
array="files"
|
|
33
|
+
object="60888216117c640e7596303f"
|
|
34
|
+
key="src"
|
|
35
35
|
type="text/css"
|
|
36
36
|
save="true" />
|
|
37
37
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
scroll="sticky-nav,hide-nav"
|
|
45
45
|
scroll-up="10"
|
|
46
46
|
scroll-down="10"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
array="files"
|
|
48
|
+
object="60395ef42b3ac232657040fd"
|
|
49
|
+
key="src"></nav>
|
|
50
50
|
<sidenav
|
|
51
51
|
id="menuL"
|
|
52
52
|
class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
|
|
53
53
|
resizable
|
|
54
|
-
resize-
|
|
54
|
+
resize-selector="[content_id='content']"
|
|
55
55
|
resize-property="margin-left"
|
|
56
56
|
resize-value="width">
|
|
57
57
|
<menu
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
array="files"
|
|
59
|
+
object="603717b07de7fb350ae9fec8"
|
|
60
|
+
key="src"></menu>
|
|
61
61
|
<div resize="right"></div>
|
|
62
62
|
</sidenav>
|
|
63
63
|
<main
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
share-width="700"
|
|
81
81
|
share-media="https://cdn.cocreate.app/docs/users.png"
|
|
82
82
|
hover="display:block!important"
|
|
83
|
-
hover-
|
|
83
|
+
hover-selector=".social-networks">
|
|
84
84
|
<div class="display:none social-networks">
|
|
85
85
|
<a
|
|
86
86
|
class="margin-right:15px"
|
|
@@ -139,11 +139,11 @@
|
|
|
139
139
|
class="border-bottom:1px_solid_lightgrey"
|
|
140
140
|
scroll
|
|
141
141
|
scroll-intersect="color:dodgerblue"
|
|
142
|
-
scroll-
|
|
142
|
+
scroll-selector="#users-install-section">
|
|
143
143
|
<span
|
|
144
144
|
class="display:flex align-items:center width:fit-content"
|
|
145
145
|
hover="display:block!important"
|
|
146
|
-
hover-
|
|
146
|
+
hover-selector="[href='#users-install']">
|
|
147
147
|
<h2 class="padding:5px_0px">Install</h2>
|
|
148
148
|
<a
|
|
149
149
|
class="margin-left:10px display:none"
|
|
@@ -165,11 +165,11 @@
|
|
|
165
165
|
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
166
166
|
scroll
|
|
167
167
|
scroll-intersect="color:dodgerblue"
|
|
168
|
-
scroll-
|
|
168
|
+
scroll-selector="#users-usage-section">
|
|
169
169
|
<span
|
|
170
170
|
class="display:flex align-items:center width:fit-content"
|
|
171
171
|
hover="display:block!important"
|
|
172
|
-
hover-
|
|
172
|
+
hover-selector="[href='#users-usage']">
|
|
173
173
|
<h2 class="padding:5px_0px">Usage</h2>
|
|
174
174
|
<a
|
|
175
175
|
class="margin-left:10px display:none"
|
|
@@ -200,11 +200,11 @@
|
|
|
200
200
|
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
201
201
|
scroll
|
|
202
202
|
scroll-intersect="color:dodgerblue"
|
|
203
|
-
scroll-
|
|
203
|
+
scroll-selector="#users-attributes-section">
|
|
204
204
|
<span
|
|
205
205
|
class="display:flex align-items:center width:fit-content"
|
|
206
206
|
hover="display:block!important"
|
|
207
|
-
hover-
|
|
207
|
+
hover-selector="[href='#users-attributes']">
|
|
208
208
|
<h2 class="padding:5px_0px">Attributes</h2>
|
|
209
209
|
<a
|
|
210
210
|
class="margin-left:10px display:none"
|
|
@@ -253,11 +253,11 @@
|
|
|
253
253
|
class="border-bottom:1px_solid_lightgrey"
|
|
254
254
|
scroll
|
|
255
255
|
scroll-intersect="color:dodgerblue"
|
|
256
|
-
scroll-
|
|
256
|
+
scroll-selector="#users-demo-section">
|
|
257
257
|
<span
|
|
258
258
|
class="display:flex align-items:center width:fit-content"
|
|
259
259
|
hover="display:block!important"
|
|
260
|
-
hover-
|
|
260
|
+
hover-selector="[href='#users-demo']">
|
|
261
261
|
<h2 class="padding:5px_0px">Demo</h2>
|
|
262
262
|
<a
|
|
263
263
|
class="margin-left:10px display:none"
|
|
@@ -281,12 +281,12 @@
|
|
|
281
281
|
<textarea
|
|
282
282
|
type="code"
|
|
283
283
|
lang="html"
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
284
|
+
array="demos"
|
|
285
|
+
object=""
|
|
286
|
+
key="demo"
|
|
287
287
|
save="false"
|
|
288
288
|
id="demo"
|
|
289
|
-
input-
|
|
289
|
+
input-selector=".demopreview"
|
|
290
290
|
input-attribute="value"
|
|
291
291
|
input-events="input, onload"
|
|
292
292
|
class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
@@ -309,7 +309,7 @@
|
|
|
309
309
|
show="#eye-slash"
|
|
310
310
|
hide="#eye, #demo-preview"
|
|
311
311
|
toggle="code-height"
|
|
312
|
-
toggle-
|
|
312
|
+
toggle-selector="#demo-code"
|
|
313
313
|
><i
|
|
314
314
|
class="height:18px fill:#505050"
|
|
315
315
|
src="/assets/svg/eye.svg"></i
|
|
@@ -321,7 +321,7 @@
|
|
|
321
321
|
show="#eye, #demo-preview"
|
|
322
322
|
hide="#eye-slash"
|
|
323
323
|
toggle="code-height"
|
|
324
|
-
toggle-
|
|
324
|
+
toggle-selector="#demo-code"
|
|
325
325
|
><i
|
|
326
326
|
class="height:20px fill:#505050"
|
|
327
327
|
src="/assets/svg/eye-slash.svg"></i
|
|
@@ -348,7 +348,7 @@
|
|
|
348
348
|
<a
|
|
349
349
|
class="margin-right:5px"
|
|
350
350
|
fullscreen
|
|
351
|
-
fullscreen-
|
|
351
|
+
fullscreen-selector="#playground"></a>
|
|
352
352
|
</div>
|
|
353
353
|
</div>
|
|
354
354
|
<!-- End SandBox -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/users",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "A simple users component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"users",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"start": "npx webpack --config webpack.config.js",
|
|
28
|
-
"build": "
|
|
28
|
+
"build": "npx webpack --mode=production --config webpack.config.js",
|
|
29
29
|
"dev": "npx webpack --config webpack.config.js --watch",
|
|
30
30
|
"postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
|
|
31
31
|
},
|
|
@@ -58,12 +58,11 @@
|
|
|
58
58
|
"webpack-log": "^3.0.1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@cocreate/actions": "^1.8.
|
|
62
|
-
"@cocreate/
|
|
63
|
-
"@cocreate/
|
|
64
|
-
"@cocreate/
|
|
65
|
-
"@cocreate/
|
|
66
|
-
"@cocreate/
|
|
67
|
-
"@cocreate/render": "^1.24.30"
|
|
61
|
+
"@cocreate/actions": "^1.8.32",
|
|
62
|
+
"@cocreate/crud-client": "^1.21.24",
|
|
63
|
+
"@cocreate/element-prototype": "^1.8.30",
|
|
64
|
+
"@cocreate/elements": "^1.17.33",
|
|
65
|
+
"@cocreate/local-storage": "^1.7.21",
|
|
66
|
+
"@cocreate/render": "^1.24.32"
|
|
68
67
|
}
|
|
69
68
|
}
|
package/src/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*globals CustomEvent, btoa*/
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import Crud from '@cocreate/crud-client';
|
|
3
|
+
import Action from '@cocreate/actions';
|
|
4
|
+
import Elements from '@cocreate/elements';
|
|
5
|
+
import Render from '@cocreate/render';
|
|
6
6
|
import '@cocreate/element-prototype';
|
|
7
7
|
import './index.css';
|
|
8
8
|
import localStorage from '@cocreate/local-storage';
|
|
@@ -15,53 +15,55 @@ const CoCreateUser = {
|
|
|
15
15
|
|
|
16
16
|
initSocket: function () {
|
|
17
17
|
const self = this;
|
|
18
|
-
|
|
18
|
+
Crud.listen('updateUserStatus', (data) => self.updateUserStatus(data));
|
|
19
19
|
},
|
|
20
20
|
|
|
21
21
|
signUp: async function (btn) {
|
|
22
22
|
let formEl = btn.closest("form");
|
|
23
23
|
if (!formEl) return;
|
|
24
24
|
|
|
25
|
-
let organization_id =
|
|
26
|
-
let
|
|
27
|
-
if (!
|
|
25
|
+
let organization_id = Crud.socket.config.organization_id;
|
|
26
|
+
let array = formEl.getAttribute('array')
|
|
27
|
+
if (!array) {
|
|
28
28
|
for (let el of formEl) {
|
|
29
|
-
|
|
30
|
-
if (
|
|
29
|
+
array = el.getAttribute('array');
|
|
30
|
+
if (array)
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
let data =
|
|
36
|
-
data
|
|
35
|
+
let data = Elements.getFormData(formEl, array)
|
|
36
|
+
data.method = 'create.object'
|
|
37
|
+
data['array'] = array
|
|
37
38
|
data.organization_id = organization_id;
|
|
38
39
|
|
|
39
|
-
if (!data.
|
|
40
|
-
data.
|
|
40
|
+
if (!data.object[0]._id)
|
|
41
|
+
data.object[0]._id = Crud.ObjectId();
|
|
41
42
|
|
|
42
|
-
let user = await
|
|
43
|
-
|
|
43
|
+
let user = await Crud.send(data)
|
|
44
|
+
Elements.setTypeValue(formEl, user)
|
|
44
45
|
|
|
45
|
-
// const socket =
|
|
46
|
+
// const socket = Crud.socket.getSockets()
|
|
46
47
|
// if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine) {
|
|
47
48
|
let key = {
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
method: 'create.object',
|
|
50
|
+
array: 'keys',
|
|
51
|
+
object: {
|
|
50
52
|
type: "user",
|
|
51
|
-
key: user.
|
|
53
|
+
key: user.object[0]._id,
|
|
52
54
|
roles: ['user'],
|
|
53
|
-
email: user.
|
|
54
|
-
password: user.
|
|
55
|
-
|
|
55
|
+
email: user.object.email,
|
|
56
|
+
password: user.object.password || btoa('0000'),
|
|
57
|
+
array
|
|
56
58
|
},
|
|
57
59
|
organization_id
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
let response = await
|
|
61
|
-
if (response && response.
|
|
62
|
-
|
|
62
|
+
let response = await Crud.send(key)
|
|
63
|
+
if (response && response.object && response.object[0]) {
|
|
64
|
+
Crud.socket.send({ method: 'signUp', user, userKey })
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
Render.data({
|
|
65
67
|
selector: "[template='signUp']",
|
|
66
68
|
data: {
|
|
67
69
|
type: 'signUp',
|
|
@@ -79,44 +81,46 @@ const CoCreateUser = {
|
|
|
79
81
|
|
|
80
82
|
signIn: function (btn) {
|
|
81
83
|
let form = btn.closest('form');
|
|
82
|
-
let
|
|
84
|
+
let array = form.getAttribute('array');
|
|
83
85
|
let query = [];
|
|
84
86
|
|
|
85
|
-
const inputs = form.querySelectorAll('input[
|
|
87
|
+
const inputs = form.querySelectorAll('input[key="email"], input[key="password"], input[key="username"]');
|
|
86
88
|
|
|
87
89
|
inputs.forEach((input) => {
|
|
88
|
-
const
|
|
90
|
+
const key = input.getAttribute('key');
|
|
89
91
|
const value = input.getValue();
|
|
90
|
-
|
|
91
|
-
query.push({
|
|
92
|
+
array = 'keys';
|
|
93
|
+
query.push({ key, value, operator: '$eq' })
|
|
92
94
|
});
|
|
93
95
|
|
|
94
96
|
let request = {
|
|
97
|
+
method: 'read.object',
|
|
95
98
|
db: 'indexeddb',
|
|
96
|
-
|
|
99
|
+
array,
|
|
97
100
|
filter: {
|
|
98
101
|
query
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
const socket =
|
|
103
|
-
if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine ||
|
|
104
|
-
|
|
105
|
+
const socket = Crud.socket.getSockets()
|
|
106
|
+
if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine || Crud.socket.serverOrganization == false) {
|
|
107
|
+
Crud.send(request).then((response) => {
|
|
105
108
|
response['success'] = false
|
|
106
109
|
response['status'] = "signIn failed"
|
|
107
|
-
if (response.
|
|
110
|
+
if (response.object && response.object[0]) {
|
|
108
111
|
response['success'] = true
|
|
109
112
|
response['status'] = "success"
|
|
110
|
-
response['user_id'] = response.
|
|
113
|
+
response['user_id'] = response.object[0].key
|
|
111
114
|
this.signInResponse(response)
|
|
112
115
|
} else {
|
|
113
116
|
this.signInResponse(response)
|
|
114
117
|
}
|
|
115
118
|
})
|
|
116
119
|
} else {
|
|
120
|
+
request.method = 'signIn'
|
|
117
121
|
request.broadcastBrowser = false
|
|
118
122
|
delete request.storage
|
|
119
|
-
|
|
123
|
+
Crud.socket.send(request).then((response) => {
|
|
120
124
|
this.signInResponse(response)
|
|
121
125
|
})
|
|
122
126
|
}
|
|
@@ -126,9 +130,9 @@ const CoCreateUser = {
|
|
|
126
130
|
let { success, status, message, user_id, token } = data;
|
|
127
131
|
|
|
128
132
|
if (success) {
|
|
129
|
-
localStorage.setItem('organization_id',
|
|
130
|
-
localStorage.setItem("key",
|
|
131
|
-
localStorage.setItem("host",
|
|
133
|
+
localStorage.setItem('organization_id', Crud.socket.config.organization_id);
|
|
134
|
+
localStorage.setItem("key", Crud.socket.config.key);
|
|
135
|
+
localStorage.setItem("host", Crud.socket.config.host);
|
|
132
136
|
localStorage.setItem('user_id', user_id);
|
|
133
137
|
localStorage.setItem("token", token);
|
|
134
138
|
// document.cookie = `token=${token};path=/`;
|
|
@@ -140,7 +144,7 @@ const CoCreateUser = {
|
|
|
140
144
|
else
|
|
141
145
|
message = "The email or password you entered is incorrect";
|
|
142
146
|
|
|
143
|
-
|
|
147
|
+
Render.data({
|
|
144
148
|
selector: "[template='signIn']",
|
|
145
149
|
data: {
|
|
146
150
|
type: 'signIn',
|
|
@@ -162,7 +166,7 @@ const CoCreateUser = {
|
|
|
162
166
|
// document.cookie = allCookies[i] + "=;expires=" +
|
|
163
167
|
// new Date(0).toUTCString();
|
|
164
168
|
|
|
165
|
-
|
|
169
|
+
Render.data({
|
|
166
170
|
selector: "[template='signOut']",
|
|
167
171
|
data: {
|
|
168
172
|
type: 'signOut',
|
|
@@ -178,7 +182,7 @@ const CoCreateUser = {
|
|
|
178
182
|
updateUserStatus: function (data) {
|
|
179
183
|
this.redirect(data)
|
|
180
184
|
if (data.user_id) {
|
|
181
|
-
let statusEls = document.querySelectorAll(`[user-status][
|
|
185
|
+
let statusEls = document.querySelectorAll(`[user-status][object='${data['user_id']}']`);
|
|
182
186
|
|
|
183
187
|
statusEls.forEach((el) => {
|
|
184
188
|
el.setAttribute('user-status', data['userStatus']);
|
|
@@ -188,9 +192,9 @@ const CoCreateUser = {
|
|
|
188
192
|
},
|
|
189
193
|
|
|
190
194
|
redirect: (data) => {
|
|
191
|
-
if (data.user_id && data.user_id !==
|
|
195
|
+
if (data.user_id && data.user_id !== Crud.socket.config.user_id)
|
|
192
196
|
return
|
|
193
|
-
if (!data.user_id && data.clientId !==
|
|
197
|
+
if (!data.user_id && data.clientId !== Crud.socket.clientId)
|
|
194
198
|
return
|
|
195
199
|
if (data.userStatus == 'on' || data.userStatus == 'idle') {
|
|
196
200
|
let redirectTag = document.querySelector('[session="true"]');
|
|
@@ -222,7 +226,8 @@ const CoCreateUser = {
|
|
|
222
226
|
let redirectTag = document.querySelector('[session]');
|
|
223
227
|
|
|
224
228
|
if (redirectTag) {
|
|
225
|
-
|
|
229
|
+
Crud.socket.send({
|
|
230
|
+
method: 'sendMessage',
|
|
226
231
|
message: 'checkSession',
|
|
227
232
|
broadcast: false,
|
|
228
233
|
broadcastSender: false,
|
|
@@ -239,27 +244,27 @@ const CoCreateUser = {
|
|
|
239
244
|
};
|
|
240
245
|
|
|
241
246
|
|
|
242
|
-
|
|
247
|
+
Action.init({
|
|
243
248
|
name: "signUp",
|
|
244
249
|
endEvent: "signUp",
|
|
245
|
-
callback: (
|
|
246
|
-
CoCreateUser.signUp(
|
|
250
|
+
callback: (data) => {
|
|
251
|
+
CoCreateUser.signUp(data.element);
|
|
247
252
|
},
|
|
248
253
|
});
|
|
249
254
|
|
|
250
|
-
|
|
255
|
+
Action.init({
|
|
251
256
|
name: "signIn",
|
|
252
257
|
endEvent: "signIn",
|
|
253
|
-
callback: (
|
|
254
|
-
CoCreateUser.signIn(
|
|
258
|
+
callback: (data) => {
|
|
259
|
+
CoCreateUser.signIn(data.element);
|
|
255
260
|
},
|
|
256
261
|
});
|
|
257
262
|
|
|
258
|
-
|
|
263
|
+
Action.init({
|
|
259
264
|
name: "signOut",
|
|
260
265
|
endEvent: "signOut",
|
|
261
|
-
callback: (
|
|
262
|
-
CoCreateUser.signOut(
|
|
266
|
+
callback: (data) => {
|
|
267
|
+
CoCreateUser.signOut(data.element);
|
|
263
268
|
},
|
|
264
269
|
});
|
|
265
270
|
|
package/src/server.js
CHANGED
|
@@ -18,19 +18,21 @@ class CoCreateUser {
|
|
|
18
18
|
try {
|
|
19
19
|
|
|
20
20
|
if (data.user) {
|
|
21
|
-
|
|
22
|
-
this.
|
|
21
|
+
data.user.method = 'create.object'
|
|
22
|
+
const response = await this.crud.send(data.user)
|
|
23
|
+
this.wsManager.broadcast(socket, response);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
if (data.userKey) {
|
|
26
|
-
|
|
27
|
-
this.
|
|
27
|
+
data.userKey.method = 'create.object'
|
|
28
|
+
const response = await this.crud.send(data.userKey)
|
|
29
|
+
this.wsManager.broadcast(socket, response);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
self.wsManager.send(socket,
|
|
32
|
+
self.wsManager.send(socket, data);
|
|
31
33
|
|
|
32
34
|
} catch (error) {
|
|
33
|
-
console.log('
|
|
35
|
+
console.log('create.object error', error);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -38,7 +40,7 @@ class CoCreateUser {
|
|
|
38
40
|
/**
|
|
39
41
|
data = {
|
|
40
42
|
namespace: string,
|
|
41
|
-
|
|
43
|
+
array: string,
|
|
42
44
|
data: object,
|
|
43
45
|
eId: string,
|
|
44
46
|
key: string,
|
|
@@ -48,8 +50,10 @@ class CoCreateUser {
|
|
|
48
50
|
async signIn(socket, data) {
|
|
49
51
|
const self = this;
|
|
50
52
|
try {
|
|
51
|
-
|
|
53
|
+
data.method = 'read.object'
|
|
54
|
+
this.crud.send(data).then(async (data) => {
|
|
52
55
|
let response = {
|
|
56
|
+
method: 'signIn',
|
|
53
57
|
success: false,
|
|
54
58
|
message: "signIn failed",
|
|
55
59
|
status: "failed",
|
|
@@ -57,8 +61,8 @@ class CoCreateUser {
|
|
|
57
61
|
uid: data.uid
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
if (data.
|
|
61
|
-
const user_id = data.
|
|
64
|
+
if (data.object[0] && data.object[0]._id && self.wsManager.authenticate) {
|
|
65
|
+
const user_id = data.object[0].key
|
|
62
66
|
const token = await self.wsManager.authenticate.generateToken({ user_id });
|
|
63
67
|
|
|
64
68
|
if (token && token != 'null') {
|
|
@@ -74,15 +78,16 @@ class CoCreateUser {
|
|
|
74
78
|
|
|
75
79
|
// if (data.organization_id != process.env.organization_id) {
|
|
76
80
|
// let Data = { organization_id: process.env.organization_id }
|
|
77
|
-
// Data.
|
|
78
|
-
// Data.
|
|
79
|
-
// Data.
|
|
80
|
-
// crud.
|
|
81
|
+
// Data.object['_id'] = data.object[0]._id
|
|
82
|
+
// Data.object['lastsignIn'] = data.object[0].lastsignIn
|
|
83
|
+
// Data.object['organization_id'] = process.env.organization_id
|
|
84
|
+
// crud.send(Data)
|
|
81
85
|
// }
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
|
-
self.wsManager.send(socket,
|
|
85
|
-
self.wsManager.broadcast(socket,
|
|
88
|
+
self.wsManager.send(socket, response)
|
|
89
|
+
self.wsManager.broadcast(socket, {
|
|
90
|
+
method: 'updateUserStatus',
|
|
86
91
|
user_id: response.user_id,
|
|
87
92
|
userStatus: response.userStatus,
|
|
88
93
|
organization_id: response.organization_id
|
|
@@ -103,15 +108,16 @@ class CoCreateUser {
|
|
|
103
108
|
try {
|
|
104
109
|
if (!data.user_id || !data.userStatus)
|
|
105
110
|
return
|
|
106
|
-
data.
|
|
107
|
-
data['
|
|
111
|
+
data.array = 'users'
|
|
112
|
+
data['object'] = {
|
|
108
113
|
_id: data.user_id,
|
|
109
114
|
userStatus: data.userStatus
|
|
110
115
|
}
|
|
111
116
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
self.wsManager.broadcast(socket,
|
|
117
|
+
data.method = 'update.object'
|
|
118
|
+
this.crud.send(data).then((data) => {
|
|
119
|
+
self.wsManager.broadcast(socket, {
|
|
120
|
+
method: 'updateUserStatus',
|
|
115
121
|
user_id: data.user_id,
|
|
116
122
|
userStatus: data.userStatus,
|
|
117
123
|
organization_id: data.organization_id || socket.config.organization_id
|
package/webpack.config.js
CHANGED
|
@@ -1,84 +1,90 @@
|
|
|
1
1
|
const path = require("path")
|
|
2
2
|
const TerserPlugin = require("terser-webpack-plugin")
|
|
3
3
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
|
4
|
-
let isProduction = process.env.NODE_ENV === "production"
|
|
5
4
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
|
|
6
5
|
|
|
7
|
-
module.exports = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
output: {
|
|
12
|
-
path: path.resolve(__dirname, "dist"),
|
|
13
|
-
filename: isProduction ? "[name].min.js" : "[name].js",
|
|
14
|
-
libraryTarget: "umd",
|
|
15
|
-
libraryExport: "default",
|
|
16
|
-
library: ["CoCreate", "users"],
|
|
17
|
-
globalObject: "this",
|
|
18
|
-
},
|
|
6
|
+
module.exports = (env, argv) => {
|
|
7
|
+
let isProduction = false
|
|
8
|
+
if (argv.mode === 'production')
|
|
9
|
+
isProduction = true
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
filename: "[name].css",
|
|
24
|
-
}),
|
|
25
|
-
],
|
|
26
|
-
// Default mode for Webpack is production.
|
|
27
|
-
// Depending on mode Webpack will apply different things
|
|
28
|
-
// on final bundle. For now we don't need production's JavaScript
|
|
29
|
-
// minifying and other thing so let's set mode to development
|
|
30
|
-
mode: isProduction ? "production" : "development",
|
|
31
|
-
module: {
|
|
32
|
-
rules: [
|
|
33
|
-
{
|
|
34
|
-
test: /.js$/,
|
|
35
|
-
exclude: /(node_modules)/,
|
|
36
|
-
use: {
|
|
37
|
-
loader: "babel-loader",
|
|
38
|
-
options: {
|
|
39
|
-
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
40
|
-
},
|
|
11
|
+
const config = {
|
|
12
|
+
entry: {
|
|
13
|
+
"CoCreate-users": "./src/index.js",
|
|
41
14
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
output: {
|
|
16
|
+
path: path.resolve(__dirname, "dist"),
|
|
17
|
+
filename: isProduction ? "[name].min.js" : "[name].js",
|
|
18
|
+
libraryTarget: "umd",
|
|
19
|
+
libraryExport: "default",
|
|
20
|
+
library: ["CoCreate", "users"],
|
|
21
|
+
globalObject: "this",
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
plugins: [
|
|
25
|
+
new CleanWebpackPlugin(),
|
|
26
|
+
new MiniCssExtractPlugin({
|
|
27
|
+
filename: "[name].css",
|
|
28
|
+
}),
|
|
48
29
|
],
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
30
|
+
// Default mode for Webpack is production.
|
|
31
|
+
// Depending on mode Webpack will apply different things
|
|
32
|
+
// on final bundle. For now we don't need production's JavaScript
|
|
33
|
+
// minifying and other thing so let's set mode to development
|
|
34
|
+
mode: isProduction ? "production" : "development",
|
|
35
|
+
module: {
|
|
36
|
+
rules: [
|
|
37
|
+
{
|
|
38
|
+
test: /.js$/,
|
|
39
|
+
exclude: /(node_modules)/,
|
|
40
|
+
use: {
|
|
41
|
+
loader: "babel-loader",
|
|
42
|
+
options: {
|
|
43
|
+
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
test: /.css$/i,
|
|
49
|
+
use: [
|
|
50
|
+
{ loader: "style-loader", options: { injectType: "linkTag" } },
|
|
51
|
+
"file-loader",
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
// add source map
|
|
58
|
+
...(isProduction ? {} : { devtool: "eval-source-map" }),
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
optimization: {
|
|
61
|
+
minimize: true,
|
|
62
|
+
minimizer: [
|
|
63
|
+
new TerserPlugin({
|
|
64
|
+
extractComments: true,
|
|
65
|
+
// cache: true,
|
|
66
|
+
parallel: true,
|
|
67
|
+
// sourceMap: true, // Must be set to true if using source-maps in production
|
|
68
|
+
terserOptions: {
|
|
69
|
+
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
|
70
|
+
// extractComments: 'all',
|
|
71
|
+
compress: {
|
|
72
|
+
drop_console: true,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
],
|
|
77
|
+
splitChunks: {
|
|
78
|
+
chunks: "all",
|
|
79
|
+
minSize: 200,
|
|
80
|
+
// maxSize: 99999,
|
|
81
|
+
//minChunks: 1,
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
83
|
+
cacheGroups: {
|
|
84
|
+
defaultVendors: false,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
return config
|
|
90
|
+
}
|