@live-change/email-service 0.8.88 → 0.8.90
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 +11 -5
- package/package.json +3 -3
package/auth.js
CHANGED
|
@@ -2,11 +2,14 @@ import definition from './definition.js'
|
|
|
2
2
|
|
|
3
3
|
const User = definition.foreignModel('user', 'User')
|
|
4
4
|
|
|
5
|
+
const preFilter = email => email.toLowerCase()
|
|
6
|
+
|
|
5
7
|
const Email = definition.model({
|
|
6
8
|
name: 'Email',
|
|
7
9
|
properties: {
|
|
8
10
|
email: {
|
|
9
11
|
type: String,
|
|
12
|
+
preFilter,
|
|
10
13
|
validation: ['nonEmpty', 'email']
|
|
11
14
|
}
|
|
12
15
|
},
|
|
@@ -92,8 +95,8 @@ definition.trigger({
|
|
|
92
95
|
}
|
|
93
96
|
},
|
|
94
97
|
async execute({ email }, context, _emit) {
|
|
95
|
-
const emailData = await Email.get(email)
|
|
96
|
-
if(emailData) throw { properties: { email: '
|
|
98
|
+
const emailData = await Email.get(preFilter(email))
|
|
99
|
+
if(emailData) throw { properties: { email: 'emailTaken' } }
|
|
97
100
|
return true
|
|
98
101
|
}
|
|
99
102
|
})
|
|
@@ -107,7 +110,7 @@ definition.trigger({
|
|
|
107
110
|
}
|
|
108
111
|
},
|
|
109
112
|
async execute({ email }, context, _emit) {
|
|
110
|
-
const emailData = await Email.get(email)
|
|
113
|
+
const emailData = await Email.get(preFilter(email))
|
|
111
114
|
if(!emailData) throw { properties: { email: 'notFound' } }
|
|
112
115
|
return emailData
|
|
113
116
|
}
|
|
@@ -122,7 +125,7 @@ definition.trigger({
|
|
|
122
125
|
}
|
|
123
126
|
},
|
|
124
127
|
async execute({ email }, context, _emit) {
|
|
125
|
-
return await Email.get(email)
|
|
128
|
+
return await Email.get(preFilter(email))
|
|
126
129
|
}
|
|
127
130
|
})
|
|
128
131
|
|
|
@@ -140,10 +143,11 @@ definition.trigger({
|
|
|
140
143
|
},
|
|
141
144
|
async execute({ user, email }, { service }, emit) {
|
|
142
145
|
if(!email) throw new Error("no email")
|
|
146
|
+
email = preFilter(email)
|
|
143
147
|
const emailData = await Email.get(email)
|
|
144
148
|
if(emailData) {
|
|
145
149
|
if(emailData.user === user) return false
|
|
146
|
-
throw { properties: { email: '
|
|
150
|
+
throw { properties: { email: 'emailTaken' } }
|
|
147
151
|
}
|
|
148
152
|
await service.trigger({ type: 'contactConnected' }, {
|
|
149
153
|
contactType: 'email_Email',
|
|
@@ -171,6 +175,7 @@ definition.trigger({
|
|
|
171
175
|
}
|
|
172
176
|
},
|
|
173
177
|
async execute({ user, email }, { client, service }, emit) {
|
|
178
|
+
email = preFilter(email)
|
|
174
179
|
const emailData = await Email.get(email)
|
|
175
180
|
if(!emailData) throw { properties: { email: 'notFound' } }
|
|
176
181
|
if(emailData.user !== user) throw { properties: { email: 'notFound' } }
|
|
@@ -191,6 +196,7 @@ definition.trigger({
|
|
|
191
196
|
},
|
|
192
197
|
waitForEvents: true,
|
|
193
198
|
async execute({ email, session }, { service }, _emit) {
|
|
199
|
+
email = preFilter(email)
|
|
194
200
|
const emailData = await Email.get(email)
|
|
195
201
|
if(!emailData) throw { properties: { email: 'notFound' } }
|
|
196
202
|
const { user } = emailData
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/email-service",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.90",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.8.
|
|
24
|
+
"@live-change/framework": "^0.8.90",
|
|
25
25
|
"got": "^11.8.3",
|
|
26
26
|
"html-to-text": "8.1.0",
|
|
27
27
|
"inline-css": "4.0.2",
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"juice": "11.0.0",
|
|
30
30
|
"nodemailer": "^6.7.2"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "745223326ab078f2155434fe684611fc1398df9d",
|
|
33
33
|
"type": "module"
|
|
34
34
|
}
|