@live-change/user-frontend 0.1.5 → 0.2.2
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/LICENSE.md +11 -0
- package/e2e/steps_file.js +55 -1
- package/front/src/App.vue +7 -1
- package/front/src/nav/UserIcon.vue +86 -0
- package/front/src/nav/UserMenu.vue +12 -0
- package/index.js +3 -0
- package/package.json +26 -26
- package/server/init-functions.js +24 -0
- package/LICENSE +0 -21
package/LICENSE.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright 2019-2022 Michał Łaszczewski
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/e2e/steps_file.js
CHANGED
|
@@ -1,7 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
const App = require('@live-change/framework')
|
|
2
|
+
const app = App.app()
|
|
3
|
+
|
|
4
|
+
const randomProfile = require('random-profile-generator')
|
|
5
|
+
const passwordGenerator = require('generate-password')
|
|
2
6
|
|
|
3
7
|
const steps = {
|
|
4
8
|
|
|
9
|
+
async haveUser(name, email, password, user = app.generateUid(), roles = []) {
|
|
10
|
+
const I = this
|
|
11
|
+
|
|
12
|
+
if(!password) password = passwordGenerator.generate({
|
|
13
|
+
length: 10,
|
|
14
|
+
numbers: true
|
|
15
|
+
})
|
|
16
|
+
if(!name) {
|
|
17
|
+
name = randomProfile.profile().firstName
|
|
18
|
+
}
|
|
19
|
+
if(!email) {
|
|
20
|
+
email = name.split(' ')[0].toLowerCase() + (Math.random()*100).toFixed() + '@test.com'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const PasswordAuthentication = await I.haveModel("passwordAuthentication", "PasswordAuthentication")
|
|
24
|
+
const User = await I.haveModel("user", "User")
|
|
25
|
+
const Email = await I.haveModel("email", "Email")
|
|
26
|
+
const Identification = await I.haveModel("userIdentification", "Identification")
|
|
27
|
+
|
|
28
|
+
const passwordHash = PasswordAuthentication.definition.properties.passwordHash.preFilter(password)
|
|
29
|
+
await User.create({ id: user, roles })
|
|
30
|
+
await PasswordAuthentication.create({ id: user, user, passwordHash })
|
|
31
|
+
await Email.create({ id: email, email, user })
|
|
32
|
+
await Identification.create({
|
|
33
|
+
id: App.encodeIdentifier(['user_User', user]), sessionOrUserType: 'user_User', sessionOrUser: user,
|
|
34
|
+
name
|
|
35
|
+
})
|
|
36
|
+
return {
|
|
37
|
+
id: user,
|
|
38
|
+
name,
|
|
39
|
+
email,
|
|
40
|
+
password
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
async amLoggedIn(user) {
|
|
45
|
+
const I = this
|
|
46
|
+
console.log("USER", user)
|
|
47
|
+
const AuthenticatedUser = await I.haveModel("user", "AuthenticatedUser")
|
|
48
|
+
const session = await I.executeScript(() => window.api.client.value.session)
|
|
49
|
+
await AuthenticatedUser.create({ id: session, session, user: user.id })
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
async amLoggedOut() {
|
|
53
|
+
const I = this
|
|
54
|
+
const AuthenticatedUser = await I.haveModel("user", "AuthenticatedUser")
|
|
55
|
+
const session = await I.executeScript(() => window.api.client.value.session)
|
|
56
|
+
await AuthenticatedUser.delete(session)
|
|
57
|
+
},
|
|
58
|
+
|
|
5
59
|
async useSecretCode(authentication, happyPath) {
|
|
6
60
|
const I = this
|
|
7
61
|
const Code = await I.haveModel('secretCode', 'Code')
|
package/front/src/App.vue
CHANGED
|
@@ -22,10 +22,16 @@
|
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
import { watch } from 'vue'
|
|
25
|
-
import { client as useClient } from '@live-change/vue3-ssr'
|
|
25
|
+
import { client as useClient, useApi } from '@live-change/vue3-ssr'
|
|
26
26
|
const client = useClient()
|
|
27
27
|
watch(client, (newClient, oldClient) => {
|
|
28
28
|
console.log("WATCH CLIENT", oldClient, '=>', newClient)
|
|
29
29
|
})
|
|
30
30
|
|
|
31
|
+
const api = useApi()
|
|
32
|
+
import emailValidator from "@live-change/email-service/clientEmailValidator.js"
|
|
33
|
+
import passwordValidator from "@live-change/password-authentication-service/clientPasswordValidator.js"
|
|
34
|
+
api.validators.email = emailValidator
|
|
35
|
+
api.validators.password = passwordValidator
|
|
36
|
+
|
|
31
37
|
</script>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a v-ripple
|
|
3
|
+
@click="showUserMenu"
|
|
4
|
+
class="static w-auto w-full surface-overlay left-0 top-100 z-1 shadow-none p-ripple">
|
|
5
|
+
<ul class="list-none p-0 m-0 flex align-items-center select-none flex-row border-top-none">
|
|
6
|
+
<li class="border-top-none">
|
|
7
|
+
<span class="flex p-0 px-3 align-items-center hover:surface-100 font-medium border-round
|
|
8
|
+
cursor-pointer transition-colors transition-duration-150 p-ripple">
|
|
9
|
+
<img v-if="ownerType == 'session_Session'" src="/images/empty-user-photo.svg"
|
|
10
|
+
class="mr-0 border-circle" style="width: 38px; height: 38px" />
|
|
11
|
+
<Image v-else-if="myIdentification?.image" :image="userData.image"
|
|
12
|
+
class="mr-0 border-circle border-1 surface-border" />
|
|
13
|
+
<img v-else :src="identiconUrl"
|
|
14
|
+
class="mr-0 border-circle border-1 surface-border" style="width: 38px; height: 38px" />
|
|
15
|
+
</span>
|
|
16
|
+
</li>
|
|
17
|
+
</ul>
|
|
18
|
+
</a>
|
|
19
|
+
<OverlayPanel v-if="isMounted" ref="overlayPanel" class="notifications-panel">
|
|
20
|
+
<loading-zone suspense>
|
|
21
|
+
<template v-slot:loading>
|
|
22
|
+
<div class="flex align-items-center justify-content-center top-0 left-0 notifications-loading">
|
|
23
|
+
<ProgressSpinner animationDuration=".5s"/>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
<template v-slot:default="{ isLoading }">
|
|
27
|
+
<working-zone>
|
|
28
|
+
<template v-slot:working>
|
|
29
|
+
<div class="fixed w-full h-full flex align-items-center justify-content-center top-0 left-0">
|
|
30
|
+
<ProgressSpinner animationDuration=".5s"/>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
<template v-slot:default="{ isWorking }">
|
|
34
|
+
<div :style="(isWorking || isLoading) ? 'filter: blur(4px)' : ''" class="working-blur">
|
|
35
|
+
<UserMenu />
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
</working-zone>
|
|
39
|
+
</template>
|
|
40
|
+
</loading-zone>
|
|
41
|
+
</OverlayPanel>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup>
|
|
45
|
+
import { Image } from "@live-change/image-frontend"
|
|
46
|
+
import OverlayPanel from 'primevue/overlaypanel'
|
|
47
|
+
import ProgressSpinner from "primevue/progressspinner"
|
|
48
|
+
import UserMenu from "./UserMenu.vue"
|
|
49
|
+
|
|
50
|
+
import { ref, computed, onMounted } from 'vue'
|
|
51
|
+
const overlayPanel = ref()
|
|
52
|
+
|
|
53
|
+
const isMounted = ref(false)
|
|
54
|
+
onMounted(() => isMounted.value = true)
|
|
55
|
+
|
|
56
|
+
function showUserMenu(event) {
|
|
57
|
+
overlayPanel.value.toggle(event)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
import { path, live, actions } from '@live-change/vue3-ssr'
|
|
61
|
+
import { client as useClient } from '@live-change/vue3-ssr'
|
|
62
|
+
import { toRefs } from '@vueuse/core'
|
|
63
|
+
|
|
64
|
+
const client = useClient()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
const ownerData = computed(
|
|
68
|
+
() => client.value.user
|
|
69
|
+
? ['user_User', client.value.user]
|
|
70
|
+
: ['session_Session', client.value.session]
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const [ownerType, owner] = toRefs(ownerData)
|
|
74
|
+
|
|
75
|
+
const identiconUrl = computed( () => `/api/identicon/jdenticon/${ownerType.value}:${owner.value}/28.svg` )
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
const [ myIdentification ] = await Promise.all([
|
|
79
|
+
live(path().userIdentification.myIdentification())
|
|
80
|
+
])
|
|
81
|
+
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<style>
|
|
85
|
+
|
|
86
|
+
</style>
|
package/index.js
CHANGED
|
@@ -7,5 +7,8 @@ import SimpleNotification from "./front/src/notifications/SimpleNotification.vue
|
|
|
7
7
|
import { notificationTypes } from "./front/src/notifications/notificationTypes.js"
|
|
8
8
|
export { NotificationsIcon, SimpleNotification, notificationTypes }
|
|
9
9
|
|
|
10
|
+
import UserIcon from "./front/src/nav/UserIcon.vue"
|
|
11
|
+
export { UserIcon }
|
|
12
|
+
|
|
10
13
|
import { userRoutes, installUserRedirects } from "./front/src/router.js"
|
|
11
14
|
export { userRoutes, installUserRedirects }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/user-frontend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"memDev": "lcli memDev --enableSessions --initScript ./init.js --dbAccess",
|
|
6
6
|
"localDevInit": "rm tmp.db; lcli localDev --enableSessions --initScript ./init.js",
|
|
@@ -20,29 +20,29 @@
|
|
|
20
20
|
"debug": "node --inspect-brk server"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@live-change/cli": "0.6.
|
|
24
|
-
"@live-change/dao": "0.5.
|
|
25
|
-
"@live-change/dao-vue3": "0.5.
|
|
26
|
-
"@live-change/dao-websocket": "0.5.
|
|
27
|
-
"@live-change/email-service": "0.2.
|
|
28
|
-
"@live-change/framework": "0.6.
|
|
29
|
-
"@live-change/identicon-service": "
|
|
30
|
-
"@live-change/image-frontend": "^0.
|
|
31
|
-
"@live-change/message-authentication-service": "0.2.
|
|
32
|
-
"@live-change/notification-service": "
|
|
33
|
-
"@live-change/password-authentication-service": "0.2.
|
|
23
|
+
"@live-change/cli": "0.6.14",
|
|
24
|
+
"@live-change/dao": "0.5.6",
|
|
25
|
+
"@live-change/dao-vue3": "0.5.6",
|
|
26
|
+
"@live-change/dao-websocket": "0.5.6",
|
|
27
|
+
"@live-change/email-service": "0.2.51",
|
|
28
|
+
"@live-change/framework": "0.6.14",
|
|
29
|
+
"@live-change/identicon-service": "0.2.51",
|
|
30
|
+
"@live-change/image-frontend": "^0.2.2",
|
|
31
|
+
"@live-change/message-authentication-service": "0.2.51",
|
|
32
|
+
"@live-change/notification-service": "0.2.51",
|
|
33
|
+
"@live-change/password-authentication-service": "0.2.51",
|
|
34
34
|
"@live-change/pattern": "0.2.1",
|
|
35
|
-
"@live-change/secret-code-service": "0.2.
|
|
36
|
-
"@live-change/secret-link-service": "0.2.
|
|
37
|
-
"@live-change/security-frontend": "^0.
|
|
38
|
-
"@live-change/security-service": "0.2.
|
|
39
|
-
"@live-change/session-service": "0.2.
|
|
40
|
-
"@live-change/timer-service": "0.2.
|
|
41
|
-
"@live-change/upload-service": "
|
|
42
|
-
"@live-change/user-identification-service": "0.2.
|
|
43
|
-
"@live-change/user-service": "0.2.
|
|
44
|
-
"@live-change/vue3-components": "0.2.
|
|
45
|
-
"@live-change/vue3-ssr": "0.2.
|
|
35
|
+
"@live-change/secret-code-service": "0.2.51",
|
|
36
|
+
"@live-change/secret-link-service": "0.2.51",
|
|
37
|
+
"@live-change/security-frontend": "^0.2.2",
|
|
38
|
+
"@live-change/security-service": "0.2.51",
|
|
39
|
+
"@live-change/session-service": "0.2.51",
|
|
40
|
+
"@live-change/timer-service": "0.2.51",
|
|
41
|
+
"@live-change/upload-service": "0.2.51",
|
|
42
|
+
"@live-change/user-identification-service": "0.2.51",
|
|
43
|
+
"@live-change/user-service": "0.2.51",
|
|
44
|
+
"@live-change/vue3-components": "0.2.15",
|
|
45
|
+
"@live-change/vue3-ssr": "0.2.15",
|
|
46
46
|
"@vueuse/core": "^9.1.0",
|
|
47
47
|
"codeceptjs-assert": "^0.0.5",
|
|
48
48
|
"codeceptjs-video-helper": "^0.1.3",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"wtfnode": "^0.9.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@live-change/codeceptjs-helper": "0.6.
|
|
68
|
+
"@live-change/codeceptjs-helper": "0.6.14",
|
|
69
69
|
"@wdio/selenium-standalone-service": "^7.20.8",
|
|
70
70
|
"codeceptjs": "^3.3.4",
|
|
71
71
|
"generate-password": "1.7.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"webdriverio": "^7.20.9"
|
|
76
76
|
},
|
|
77
77
|
"author": "",
|
|
78
|
-
"license": "
|
|
78
|
+
"license": "BSD-3-Clause",
|
|
79
79
|
"description": "",
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "f7abc1d907b85c321e629086c162e4b622eee91b"
|
|
81
81
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const App = require('@live-change/framework')
|
|
2
|
+
const app = App.app()
|
|
3
|
+
|
|
4
|
+
async function createUser(services, name, email, password, user = app.generateUid(), roles = []) {
|
|
5
|
+
const { PasswordAuthentication } = services.passwordAuthentication.models
|
|
6
|
+
|
|
7
|
+
const passwordHash = PasswordAuthentication.definition.properties.passwordHash.preFilter(password)
|
|
8
|
+
await services.user.models.User.create({ id: user, roles })
|
|
9
|
+
await PasswordAuthentication.create({ id: user, user, passwordHash })
|
|
10
|
+
await services.email.models.Email.create({ id: email, email, user })
|
|
11
|
+
await services.userIdentification.models.Identification.create({
|
|
12
|
+
id: App.encodeIdentifier(['user_User', user]), sessionOrUserType: 'user_User', sessionOrUser: user,
|
|
13
|
+
name
|
|
14
|
+
})
|
|
15
|
+
return {
|
|
16
|
+
id: user,
|
|
17
|
+
name,
|
|
18
|
+
email,
|
|
19
|
+
password
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = { createUser }
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Michał Łaszczewski
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|