mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
fix delete users db permission error
This commit is contained in:
parent
fdd9b10bf0
commit
5a8e2c40c7
2 changed files with 14 additions and 3 deletions
|
|
@ -39,6 +39,9 @@ import * as jwt from 'jsonwebtoken'
|
|||
import { createUser } from '../../services/create_user'
|
||||
import { comparePassword, hashPassword } from '../../utils/auth'
|
||||
import { deletePagesByParam } from '../../elastic/pages'
|
||||
import { setClaims } from '../../entity/utils'
|
||||
import { User as UserEntity } from '../../entity/user'
|
||||
import { AppDataSource } from '../../server'
|
||||
|
||||
export const updateUserResolver = authorized<
|
||||
UpdateUserSuccess,
|
||||
|
|
@ -388,9 +391,12 @@ export const deleteAccountResolver = authorized<
|
|||
},
|
||||
})
|
||||
|
||||
const deletedUser = await models.user.delete(userID)
|
||||
if ('error' in deletedUser) {
|
||||
log.error('Error deleting user account', deletedUser.error)
|
||||
const result = await AppDataSource.transaction(async (t) => {
|
||||
await setClaims(t, claims.uid)
|
||||
return t.getRepository(UserEntity).delete(userID)
|
||||
})
|
||||
if (!result.affected) {
|
||||
log.error('Error deleting user account')
|
||||
|
||||
return {
|
||||
errorCodes: [DeleteAccountErrorCode.UserNotFound],
|
||||
|
|
|
|||
|
|
@ -10950,6 +10950,11 @@ color-support@^1.1.2:
|
|||
resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2"
|
||||
integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==
|
||||
|
||||
color2k@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/color2k/-/color2k-2.0.0.tgz#86992c82e248c29f524023ed0822bc152c4fa670"
|
||||
integrity sha512-DWX9eXOC4fbJNiuvdH4QSHvvfLWyFo9TuFp7V9OzdsbPAdrWAuYc8qvFP2bIQ/LKh4LrAVnJ6vhiQYPvAHdtTg==
|
||||
|
||||
color@3.0.x:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/color/-/color-3.0.0.tgz#d920b4328d534a3ac8295d68f7bd4ba6c427be9a"
|
||||
|
|
|
|||
Loading…
Reference in a new issue