@live-change/user-service 0.9.213 → 0.9.214
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/authenticator.js +13 -6
- package/package.json +4 -4
package/authenticator.js
CHANGED
|
@@ -11,11 +11,15 @@ definition.authenticator({
|
|
|
11
11
|
console.log('[auth] credentialsObservable start', {
|
|
12
12
|
name: 'user',
|
|
13
13
|
session: credentials.session,
|
|
14
|
-
ip: credentials.ip
|
|
14
|
+
ip: credentials.ip,
|
|
15
|
+
at: new Date().toISOString()
|
|
15
16
|
})
|
|
16
17
|
return app.dao.observable(
|
|
17
18
|
['database', 'queryObject', app.databaseName, `(${
|
|
18
19
|
async (input, output, { session, authenticatedTableName, userTableName }) => {
|
|
20
|
+
const queryId = (Math.random()*10000).toFixed(0)
|
|
21
|
+
const ts = () => new Date().toISOString()
|
|
22
|
+
output.debug(ts(), queryId, 'STARTING USER AUTH QUERY', { session })
|
|
19
23
|
const authenticatedTable = input.table(authenticatedTableName)
|
|
20
24
|
const userTable = input.table(userTableName)
|
|
21
25
|
let user = null
|
|
@@ -23,10 +27,10 @@ definition.authenticator({
|
|
|
23
27
|
let userObserver = null
|
|
24
28
|
let oldCredentials = null
|
|
25
29
|
await authenticatedTable.object(session).onChange(async (authData, oldAuthData) => {
|
|
26
|
-
output.debug("NEW USER AUTH", authData, "FROM", oldAuthData)
|
|
27
30
|
const newUser = authData ? authData.user : null
|
|
31
|
+
output.debug(ts(), queryId, "AUTH DATA CHANGE TO", authData, "FROM", oldAuthData, "NEW USER", newUser, "OLD USER", user)
|
|
28
32
|
if(newUser === user) return
|
|
29
|
-
output.debug("USER CHANGE", user, '=>', newUser)
|
|
33
|
+
output.debug(ts(), queryId, "USER CHANGE", user, '=>', newUser)
|
|
30
34
|
if(user) {
|
|
31
35
|
if(userObject) {
|
|
32
36
|
await userObject.unobserve(userObserver)
|
|
@@ -38,13 +42,14 @@ definition.authenticator({
|
|
|
38
42
|
user = newUser
|
|
39
43
|
userObject = userTable.object(user)
|
|
40
44
|
const currentUserObject = userObject
|
|
45
|
+
output.debug(ts(), queryId, "USER ON CHANGE START", { user })
|
|
41
46
|
await userObject.onChange(async (userData, oldUserData) => {
|
|
42
47
|
const newCredentials = userData ? {
|
|
43
48
|
id: user,
|
|
44
49
|
user,
|
|
45
50
|
roles: userData.roles
|
|
46
51
|
} : null
|
|
47
|
-
output.debug("NEW CREDENTIALS", newCredentials)
|
|
52
|
+
//output.debug("NEW CREDENTIALS", newCredentials)
|
|
48
53
|
output.change(newCredentials, oldCredentials)
|
|
49
54
|
oldCredentials = newCredentials
|
|
50
55
|
}).then(observer => {
|
|
@@ -54,14 +59,16 @@ definition.authenticator({
|
|
|
54
59
|
currentUserObject.unobserve(observer)
|
|
55
60
|
}
|
|
56
61
|
})
|
|
62
|
+
output.debug(ts(), queryId, "USER ON CHANGE END", { user })
|
|
57
63
|
} else {
|
|
58
|
-
output.debug("USER NULL", user)
|
|
59
|
-
output.debug("OLD CREDENTIALS", oldCredentials)
|
|
64
|
+
//output.debug("USER NULL", user)
|
|
65
|
+
//output.debug("OLD CREDENTIALS", oldCredentials)
|
|
60
66
|
user = null
|
|
61
67
|
output.change(null, oldCredentials)
|
|
62
68
|
oldCredentials = null
|
|
63
69
|
}
|
|
64
70
|
})
|
|
71
|
+
output.debug(ts(), queryId, "AUTH DATA ON CHANGE END", { session })
|
|
65
72
|
}
|
|
66
73
|
})`, {
|
|
67
74
|
session: credentials.session,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/user-service",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.214",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@live-change/framework": "^0.9.
|
|
26
|
-
"@live-change/relations-plugin": "^0.9.
|
|
25
|
+
"@live-change/framework": "^0.9.214",
|
|
26
|
+
"@live-change/relations-plugin": "^0.9.214",
|
|
27
27
|
"pluralize": "^8.0.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "f9d690b526b0a524c2e7abf8667ede76988a0e5a"
|
|
30
30
|
}
|