@live-change/email-service 0.2.2 → 0.2.6
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/auth.js +24 -1
- package/package.json +2 -2
package/auth.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
const { validation } = require('@live-change/framework')
|
|
1
2
|
const definition = require('./definition.js')
|
|
2
3
|
|
|
3
4
|
const User = definition.foreignModel('user', 'User')
|
|
4
5
|
|
|
5
6
|
const Email = definition.model({
|
|
6
7
|
name: 'Email',
|
|
8
|
+
properties: {
|
|
9
|
+
email: {
|
|
10
|
+
type: String,
|
|
11
|
+
validation: ['nonEmpty', 'email']
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
userItem: {
|
|
8
15
|
userReadAccess: () => true
|
|
9
16
|
},
|
|
@@ -66,6 +73,21 @@ definition.trigger({
|
|
|
66
73
|
}
|
|
67
74
|
})
|
|
68
75
|
|
|
76
|
+
definition.trigger({
|
|
77
|
+
name: "getEmail",
|
|
78
|
+
properties: {
|
|
79
|
+
email: {
|
|
80
|
+
type: String,
|
|
81
|
+
validation: ['nonEmpty', 'email']
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
async execute({ email }, context, emit) {
|
|
85
|
+
const emailData = await Email.get(email)
|
|
86
|
+
if(!emailData) throw 'notFound'
|
|
87
|
+
return emailData
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
|
|
69
91
|
definition.trigger({
|
|
70
92
|
name: "connectEmail",
|
|
71
93
|
properties: {
|
|
@@ -79,6 +101,7 @@ definition.trigger({
|
|
|
79
101
|
}
|
|
80
102
|
},
|
|
81
103
|
async execute({ user, email }, { client, service }, emit) {
|
|
104
|
+
if(!email) throw new Error("no email")
|
|
82
105
|
const emailData = await Email.get(email)
|
|
83
106
|
if(emailData) throw 'taken'
|
|
84
107
|
emit({
|
|
@@ -119,7 +142,7 @@ definition.trigger({
|
|
|
119
142
|
type: String
|
|
120
143
|
}
|
|
121
144
|
},
|
|
122
|
-
async execute({ email }, { client, service }, emit) {
|
|
145
|
+
async execute({ email, session }, { client, service }, emit) {
|
|
123
146
|
const emailData = await Email.get(email)
|
|
124
147
|
if(!emailData) throw 'emailNotFound'
|
|
125
148
|
const { user } = emailData
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/email-service",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"jsdom": "^18.1.1",
|
|
29
29
|
"nodemailer": "^6.7.2"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "2491e82b350403cf187887e8f06d140e0c362860"
|
|
32
32
|
}
|