@live-change/user-service
Advanced tools
Comparing version 0.2.10 to 0.2.11
22
index.js
@@ -43,2 +43,4 @@ const app = require("@live-change/framework").app() | ||
async execute({ user, session }, { client, service }, emit) { | ||
const userData = await User.get(user) | ||
if(!userData) throw 'userNotFound' | ||
emit({ | ||
@@ -89,3 +91,23 @@ type: "signedIn", | ||
definition.action({ | ||
name: 'deleteMe', | ||
properties: { | ||
}, | ||
access: (params, { client }) => { | ||
return !!client.user | ||
}, | ||
async execute({ }, { client, service }, emit) { | ||
const user = client.user | ||
await service.trigger({ | ||
type: 'userDeleted', | ||
user | ||
}) | ||
emit([{ | ||
type: "deleted", | ||
user | ||
}]) | ||
return user | ||
} | ||
}) | ||
module.exports = definition |
13
model.js
@@ -75,2 +75,15 @@ const definition = require('./definition.js') | ||
definition.event({ | ||
name: "deleted", | ||
properties: { | ||
user: { | ||
type: User | ||
} | ||
}, | ||
async execute({ user }) { | ||
const authenticated = await AuthenticatedUser.indexRangeGet('byUser', user) | ||
await Promise.all([ User.delete(user) ].concat(authenticated.map(auth => AuthenticatedUser.delete(auth)))) | ||
} | ||
}) | ||
module.exports = { User, AuthenticatedUser } |
{ | ||
"name": "@live-change/user-service", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"description": "", | ||
@@ -27,3 +27,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "ae86524e5ac7052eb6b6e7b34e319373b6bdef23" | ||
"gitHead": "2b95c89678f276d6b3a039652169c5fc819df8df" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19355
522