[CORL-523] Document GraphQL mutations for managing accounts (#2544)

* Create preliminary endpoint for updating user names via API

CORL-523

* Create preliminary endpoint for updating user emails via API

CORL-523

* Create preliminary endpoint for deleting users via the API

CORL-523

* Hook up the delete, update email, and update user name endpoints

CORL-523

* Update readme to include preliminary GDPR endpoint instructions

CORL-523

* Uncomment limiters on updateEmail endpoint

My mistake leaving these commented while testing, should not have been committed.

CORL-523

* Run DocToc on the README to generate table of contents

CORL-523

* feat: enhanced documentation on account management edges

* fix: prevent double delete of user account

* fix: swapped order of params

* Update README.md

* Update README.md

* fix: remove unknown field title

* fix: remove unknown field title on story
This commit is contained in:
Nick Funk
2019-09-10 20:16:40 +07:00
committed by Vinh
parent e86e9d2c68
commit f9e1bf144e
7 changed files with 530 additions and 211 deletions
+39
View File
@@ -1,4 +1,5 @@
import bcrypt from "bcryptjs";
import { DateTime, DurationObject } from "luxon";
import { Db, MongoError } from "mongodb";
import uuid from "uuid";
@@ -2136,3 +2137,41 @@ export async function pullUserNotificationDigests(
return result.value || null;
}
/**
* retrieveUserScheduledForDeletion will return a user that is scheduled for
* deletion as well as create a reschedule date in the future.
*
* @param mongo the database to pull scheduled users to delete from
* @param tenantID the tenant ID to pull users that have been scheduled for
* deletion on
* @param now the current time
*/
export async function retrieveUserScheduledForDeletion(
mongo: Db,
tenantID: string,
rescheduledDuration: DurationObject,
now: Date
) {
const rescheduledDeletionDate = DateTime.fromJSDate(now)
.plus(rescheduledDuration)
.toJSDate();
const result = await collection(mongo).findOneAndUpdate(
{
tenantID,
scheduledDeletionDate: { $lte: now },
},
{
$set: {
scheduledDeletionDate: rescheduledDeletionDate,
},
},
{
// We want to get back the user with
// modified scheduledDeletionDate
returnOriginal: false,
}
);
return result.value || null;
}