@live-change/email-service 0.2.6 → 0.2.8
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 +19 -10
- package/package.json +2 -2
package/auth.js
CHANGED
|
@@ -13,11 +13,6 @@ const Email = definition.model({
|
|
|
13
13
|
},
|
|
14
14
|
userItem: {
|
|
15
15
|
userReadAccess: () => true
|
|
16
|
-
},
|
|
17
|
-
indexes: {
|
|
18
|
-
byEmail: {
|
|
19
|
-
property: 'email'
|
|
20
|
-
}
|
|
21
16
|
}
|
|
22
17
|
})
|
|
23
18
|
|
|
@@ -68,7 +63,7 @@ definition.trigger({
|
|
|
68
63
|
},
|
|
69
64
|
async execute({ email }, context, emit) {
|
|
70
65
|
const emailData = await Email.get(email)
|
|
71
|
-
if(emailData) throw 'taken'
|
|
66
|
+
if(emailData) throw { properties: { email: 'taken' } }
|
|
72
67
|
return true
|
|
73
68
|
}
|
|
74
69
|
})
|
|
@@ -83,7 +78,21 @@ definition.trigger({
|
|
|
83
78
|
},
|
|
84
79
|
async execute({ email }, context, emit) {
|
|
85
80
|
const emailData = await Email.get(email)
|
|
86
|
-
if(!emailData) throw 'notFound'
|
|
81
|
+
if(!emailData) throw { properties: { email: 'notFound' } }
|
|
82
|
+
return emailData
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
definition.trigger({
|
|
87
|
+
name: "getEmailOrNull",
|
|
88
|
+
properties: {
|
|
89
|
+
email: {
|
|
90
|
+
type: String,
|
|
91
|
+
validation: ['nonEmpty', 'email']
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
async execute({ email }, context, emit) {
|
|
95
|
+
const emailData = await Email.get(email)
|
|
87
96
|
return emailData
|
|
88
97
|
}
|
|
89
98
|
})
|
|
@@ -103,7 +112,7 @@ definition.trigger({
|
|
|
103
112
|
async execute({ user, email }, { client, service }, emit) {
|
|
104
113
|
if(!email) throw new Error("no email")
|
|
105
114
|
const emailData = await Email.get(email)
|
|
106
|
-
if(emailData) throw 'taken'
|
|
115
|
+
if(emailData) throw { properties: { email: 'taken' } }
|
|
107
116
|
emit({
|
|
108
117
|
type: 'emailConnected',
|
|
109
118
|
user, email
|
|
@@ -126,7 +135,7 @@ definition.trigger({
|
|
|
126
135
|
},
|
|
127
136
|
async execute({ user, email }, { client, service }, emit) {
|
|
128
137
|
const emailData = await Email.get(email)
|
|
129
|
-
if(!emailData) throw 'notFound'
|
|
138
|
+
if(!emailData) throw { properties: { email: 'notFound' } }
|
|
130
139
|
emit({
|
|
131
140
|
type: 'emailDisconnected',
|
|
132
141
|
user, email
|
|
@@ -144,7 +153,7 @@ definition.trigger({
|
|
|
144
153
|
},
|
|
145
154
|
async execute({ email, session }, { client, service }, emit) {
|
|
146
155
|
const emailData = await Email.get(email)
|
|
147
|
-
if(!emailData) throw '
|
|
156
|
+
if(!emailData) throw { properties: { email: 'notFound' } }
|
|
148
157
|
const { user } = emailData
|
|
149
158
|
return service.trigger({
|
|
150
159
|
type: 'signIn',
|
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.8",
|
|
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": "1e8102d02b6745fea401e967c211c6a9cb03e19b"
|
|
32
32
|
}
|