@live-change/google-authentication-service 0.9.193 → 0.9.195
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/connect.js +6 -6
- package/offlineAccess.js +2 -2
- package/package.json +4 -4
- package/sign.js +2 -2
package/connect.js
CHANGED
|
@@ -46,9 +46,9 @@ definition.trigger({
|
|
|
46
46
|
await downloadData(user, data, context)
|
|
47
47
|
return
|
|
48
48
|
}
|
|
49
|
-
throw
|
|
49
|
+
throw app.logicError("alreadyConnectedElsewhere")
|
|
50
50
|
}
|
|
51
|
-
throw
|
|
51
|
+
throw app.logicError("alreadyConnected")
|
|
52
52
|
}
|
|
53
53
|
emit({
|
|
54
54
|
type: 'accountConnected',
|
|
@@ -71,7 +71,7 @@ definition.trigger({
|
|
|
71
71
|
},
|
|
72
72
|
async execute({ account }, { client, service, triggerService }, emit) {
|
|
73
73
|
const accountData = await Account.get(account)
|
|
74
|
-
if(!accountData) throw
|
|
74
|
+
if(!accountData) throw app.logicError("notFound")
|
|
75
75
|
const { user } = accountData
|
|
76
76
|
|
|
77
77
|
let offlineAccess
|
|
@@ -121,7 +121,7 @@ definition.action({
|
|
|
121
121
|
},
|
|
122
122
|
async execute({ code, redirectUri, transferOwnership }, { client, service }, emit) {
|
|
123
123
|
const user = client.user
|
|
124
|
-
if(!user) throw
|
|
124
|
+
if(!user) throw app.logicError("notAuthorized")
|
|
125
125
|
const tokens = await getTokensWithCode(code, redirectUri)
|
|
126
126
|
debug("TOKENS", tokens)
|
|
127
127
|
const googleUser = await getUserInfo(tokens.access_token)
|
|
@@ -148,9 +148,9 @@ definition.action({
|
|
|
148
148
|
},
|
|
149
149
|
async execute({ account }, { client, service }, emit) {
|
|
150
150
|
const accountData = await Account.get(account)
|
|
151
|
-
if(!accountData) throw
|
|
151
|
+
if(!accountData) throw app.logicError("notFound")
|
|
152
152
|
const { user } = accountData
|
|
153
|
-
if(user !== client.user) throw
|
|
153
|
+
if(user !== client.user) throw app.logicError("notAuthorized")
|
|
154
154
|
await service.trigger({ type: 'disconnectGoogle' }, {
|
|
155
155
|
user, account
|
|
156
156
|
})
|
package/offlineAccess.js
CHANGED
|
@@ -138,7 +138,7 @@ definition.action({
|
|
|
138
138
|
},
|
|
139
139
|
async execute({ code, redirectUri, scope }, { client, service }, emit) {
|
|
140
140
|
const user = client.user
|
|
141
|
-
if(!user) throw
|
|
141
|
+
if(!user) throw app.logicError("notAuthorized")
|
|
142
142
|
const tokens = await getTokensWithCode(code, redirectUri)
|
|
143
143
|
console.log("TOKENS", tokens)
|
|
144
144
|
if(!tokens.refresh_token) throw new Error("No refresh token")
|
|
@@ -150,7 +150,7 @@ definition.action({
|
|
|
150
150
|
const accountData = await Account.get(account)
|
|
151
151
|
console.log("ACCOUNT DATA", accountData, 'CURRENT USER', user)
|
|
152
152
|
if(accountData) {
|
|
153
|
-
if(accountData.user !== user) throw
|
|
153
|
+
if(accountData.user !== user) throw app.logicError("connectedToAnotherUser")
|
|
154
154
|
} else {
|
|
155
155
|
await service.trigger({ type: 'connectGoogle' }, {
|
|
156
156
|
user, account, data: googleUser,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/google-authentication-service",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.195",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.9.
|
|
25
|
-
"@live-change/relations-plugin": "^0.9.
|
|
24
|
+
"@live-change/framework": "^0.9.195",
|
|
25
|
+
"@live-change/relations-plugin": "^0.9.195",
|
|
26
26
|
"google-auth-library": "9.0.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "9f61eddae56ddd89aba20988b8e208d948728496",
|
|
29
29
|
"type": "module"
|
|
30
30
|
}
|
package/sign.js
CHANGED
|
@@ -61,7 +61,7 @@ definition.action({
|
|
|
61
61
|
user
|
|
62
62
|
}
|
|
63
63
|
} else { // Sign up
|
|
64
|
-
throw
|
|
64
|
+
throw app.logicError("notFound")
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
})
|
|
@@ -92,7 +92,7 @@ definition.action({
|
|
|
92
92
|
const existingLogin = await Account.get(account)
|
|
93
93
|
const { session } = client
|
|
94
94
|
if(existingLogin) { /// Sign In
|
|
95
|
-
throw
|
|
95
|
+
throw app.logicError("alreadyConnected")
|
|
96
96
|
} else { // Sign up
|
|
97
97
|
const user = app.generateUid()
|
|
98
98
|
await service.trigger({ type: 'connectGoogle' }, {
|