-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(anonymisation): anonymiser les utiliseurs quand on le supprime en mettant leur initiales #1480
Changes from 5 commits
7493e9b
cc09eb8
815ce43
5406536
6cc7f9c
9145b27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,28 +12,36 @@ const deleteQuery = gql` | |
isDeleted: true | ||
} | ||
) { | ||
name | ||
id | ||
} | ||
} | ||
`; | ||
|
||
interface DeleteUserHasuraResult { | ||
update_auth_users_by_pk: { | ||
name: string; | ||
id: string; | ||
}; | ||
} | ||
|
||
export const deleteUser = async (userId: string): Promise<boolean> => { | ||
const anonymizeUser = (userName: string, userId: string): string => { | ||
if (!userName?.length) return userId.slice(4); | ||
return userName.toUpperCase().split(" ").map((word) => word[0]).join(); | ||
}; | ||
|
||
export const deleteUser = async ( | ||
userId: string, | ||
userName: string | ||
): Promise<boolean> => { | ||
const deleteResult = await gqlClient() | ||
.mutation<DeleteUserHasuraResult>(deleteQuery, { | ||
email: `${userId}@gouv.fr`, | ||
id: userId, | ||
name: userId, | ||
name: anonymizeUser(userName, userId), | ||
}) | ||
.toPromise(); | ||
|
||
if ( | ||
deleteResult.data?.update_auth_users_by_pk.name !== userId || | ||
deleteResult.data?.update_auth_users_by_pk.id !== userId || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Du coup on avait un bug ici ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non avant comme le nom était l'id on checkait le nom et ça marchait mais maintenant il faut bien checker sur l'id |
||
deleteResult.error | ||
) { | ||
return false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- alter table "contribution"."answers" alter column "display_date" drop not null; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
UPDATE auth.users | ||
SET name = 'CL' | ||
WHERE id = '62a6e4c1-2624-4dfb-b984-0d206ec8a43e'; | ||
|
||
UPDATE auth.users | ||
SET name = 'FD' | ||
WHERE id = '474702f8-7f7e-4f05-92b2-45796a075e0f'; | ||
|
||
UPDATE auth.users | ||
SET name = 'AB' | ||
WHERE id = '1baef8d6-e871-46b4-8150-1f587b9f56cd'; | ||
|
||
UPDATE auth.users | ||
SET name = 'CL' | ||
WHERE id = 'aa6d1721-71e5-42a8-bf26-98f453d1fab5'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ca a du être sympa de retrouver les personnes 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. j'ai regardé dans le fichier audit ^^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pratique cette table audit :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
désolé 🙈