Fix account deletion.
This commit is contained in:
parent
5a7e695e53
commit
971d454e2c
9 changed files with 76 additions and 13 deletions
|
@ -64,6 +64,24 @@ export async function settings(ctx) {
|
|||
ctx.body = {};
|
||||
}
|
||||
|
||||
export async function deleteUser(ctx) {
|
||||
ctx.assert(
|
||||
ctx.request.body, 400,
|
||||
'{"error": {"message": "Current Password required to update account.", "code": 612}}',
|
||||
);
|
||||
ctx.assert(
|
||||
ctx.request.body.current_password, 400,
|
||||
'{"error": {"message": "Current Password required to update account.", "code": 612}}',
|
||||
);
|
||||
const user = await models.user.findByPk(ctx.user.id);
|
||||
ctx.assert(
|
||||
await passwords.match(ctx.request.body.current_password, user.password), 400,
|
||||
'{"error": {"message": "Incorrect password", "code": 606}}',
|
||||
);
|
||||
await user.destroy();
|
||||
ctx.body = '{"action":"logout", "message": "Account deleted"}';
|
||||
}
|
||||
|
||||
export async function events(ctx) {
|
||||
const pubsub = redis.createClient(redisUrl);
|
||||
pubsub.on('message', (channel, message) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue