mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Merge branch 'develop' into release
This commit is contained in:
@@ -245,6 +245,10 @@ api.updatePassword = {
|
||||
},
|
||||
newPassword: {
|
||||
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
||||
isLength: {
|
||||
options: { min: common.constants.MINIMUM_PASSWORD_LENGTH },
|
||||
errorMessage: res.t('minPasswordLength'),
|
||||
},
|
||||
},
|
||||
confirmPassword: {
|
||||
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
||||
@@ -387,13 +391,23 @@ api.resetPasswordSetNewOne = {
|
||||
|
||||
if (!isValidCode) throw new NotAuthorized(res.t('invalidPasswordResetCode'));
|
||||
|
||||
req.checkBody('newPassword', res.t('missingNewPassword')).notEmpty();
|
||||
req.checkBody('confirmPassword', res.t('missingNewPassword')).notEmpty();
|
||||
req.checkBody({
|
||||
newPassword: {
|
||||
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
||||
isLength: {
|
||||
options: { min: common.constants.MINIMUM_PASSWORD_LENGTH },
|
||||
errorMessage: res.t('minPasswordLength'),
|
||||
},
|
||||
},
|
||||
confirmPassword: {
|
||||
notEmpty: { errorMessage: res.t('missingNewPassword') },
|
||||
},
|
||||
});
|
||||
|
||||
const validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
|
||||
const { newPassword } = req.body;
|
||||
const { confirmPassword } = req.body;
|
||||
const { newPassword, confirmPassword } = req.body;
|
||||
|
||||
if (newPassword !== confirmPassword) {
|
||||
throw new BadRequest(res.t('passwordConfirmationMatch'));
|
||||
|
||||
@@ -254,19 +254,23 @@ api.joinChallenge = {
|
||||
|
||||
const challenge = await Challenge.findOne({ _id: req.params.challengeId }).exec();
|
||||
if (!challenge) throw new NotFound(res.t('challengeNotFound'));
|
||||
if (challenge.isMember(user)) throw new NotAuthorized(res.t('userAlreadyInChallenge'));
|
||||
|
||||
const group = await Group.getGroup({
|
||||
user, groupId: challenge.group, fields: basicGroupFields, optionalMembership: true,
|
||||
});
|
||||
if (!group || !challenge.canJoin(user, group)) throw new NotFound(res.t('challengeNotFound'));
|
||||
|
||||
const addedSuccessfully = await challenge.addToUser(user);
|
||||
if (!addedSuccessfully) {
|
||||
throw new NotAuthorized(res.t('userAlreadyInChallenge'));
|
||||
}
|
||||
|
||||
challenge.memberCount += 1;
|
||||
|
||||
addUserJoinChallengeNotification(user);
|
||||
|
||||
// Add all challenge's tasks to user's tasks and save the challenge
|
||||
const results = await Promise.all([challenge.syncToUser(user), challenge.save()]);
|
||||
const results = await Promise.all([challenge.syncTasksToUser(user), challenge.save()]);
|
||||
|
||||
const response = results[1].toJSON();
|
||||
response.group = getChallengeGroupResponse(group);
|
||||
|
||||
@@ -76,10 +76,12 @@ const requiredGroupFields = '_id leader tasksOrder name';
|
||||
* include: a UUID, startDate and time.
|
||||
* For example {"id":"ed427623-9a69-4aac-9852-13deb9c190c3",
|
||||
* "startDate":"1/16/17","time":"1/16/17" }
|
||||
* @apiParam (Body) {String="weekly","daily"} [frequency=weekly] Value "weekly" enables
|
||||
* "On days of the week", value
|
||||
* "daily" enables "EveryX Days".
|
||||
* Only valid for type "daily".
|
||||
* @apiParam (Body) {String="daily","weekly","monthly","yearly"} [frequency=weekly] Values "weekly"
|
||||
* and "monthly" enable use of the "repeat" field.
|
||||
* All frequency values enable use of the "everyX" field.
|
||||
* Value "monthly" enables use of the "weeksOfMonth" and
|
||||
* "daysOfMonth" fields.
|
||||
* Frequency is only valid for type "daily".
|
||||
* @apiParam (Body) {String} [repeat=true] List of objects for days of the week,
|
||||
* Days that are true will be repeated upon.
|
||||
* Only valid for type "daily". Any days not specified
|
||||
@@ -92,6 +94,10 @@ const requiredGroupFields = '_id leader tasksOrder name';
|
||||
* task is available again.
|
||||
* @apiParam (Body) {Number} [streak=0] Number of days that the task has consecutively
|
||||
* been checked off. Only valid for type "daily"
|
||||
* @apiParam (Body) {Integer[]} daysOfMonth Array of integers.
|
||||
* Only valid for type "daily"
|
||||
* @apiParam (Body) {Integer[]} weeksOfMonth Array of integers.
|
||||
* Only valid for type "daily"
|
||||
* @apiParam (Body) {Date} [startDate] Date when the task will first become available.
|
||||
* Only valid for type "daily"
|
||||
* @apiParam (Body) {Boolean} [up=true] Only valid for type "habit"
|
||||
@@ -240,10 +246,12 @@ api.createUserTasks = {
|
||||
* include: a UUID, startDate and time.
|
||||
* For example {"id":"ed427623-9a69-4aac-9852-13deb9c190c3",
|
||||
* "startDate":"1/16/17","time":"1/16/17" }
|
||||
* @apiParam (Body) {String="weekly","daily"} [frequency=weekly] Value "weekly" enables
|
||||
* "On days of the week", value
|
||||
* "daily" enables "EveryX Days".
|
||||
* Only valid for type "daily".
|
||||
* @apiParam (Body) {String="daily","weekly","monthly","yearly"} [frequency=weekly] Values "weekly"
|
||||
* and "monthly" enable use of the "repeat" field.
|
||||
* All frequency values enable use of the "everyX" field.
|
||||
* Value "monthly" enables use of the "weeksOfMonth" and
|
||||
* "daysOfMonth" fields.
|
||||
* Frequency is only valid for type "daily".
|
||||
* @apiParam (Body) {String} [repeat=true] List of objects for days of the week,
|
||||
* Days that are true will be repeated upon.
|
||||
* Only valid for type "daily". Any days not
|
||||
@@ -255,6 +263,10 @@ api.createUserTasks = {
|
||||
* of days until this daily task is available again.
|
||||
* @apiParam (Body) {Number} [streak=0] Number of days that the task has consecutively
|
||||
* been checked off. Only valid for type "daily"
|
||||
* @apiParam (Body) {Integer[]} daysOfMonth Array of integers.
|
||||
* Only valid for type "daily"
|
||||
* @apiParam (Body) {Integer[]} weeksOfMonth Array of integers.
|
||||
* Only valid for type "daily"
|
||||
* @apiParam (Body) {Date} [startDate] Date when the task will first become available.
|
||||
* Only valid for type "daily"
|
||||
* @apiParam (Body) {Boolean} [up=true] Only valid for type "habit" If true,
|
||||
@@ -544,10 +556,12 @@ api.getTask = {
|
||||
* Easy, Medium, Hard.
|
||||
* @apiParam (Body) {String[]} [reminders] Array of reminders, each an object that must include:
|
||||
* a UUID, startDate and time.
|
||||
* @apiParam (Body) {String="weekly","daily"} [frequency=weekly] Value "weekly" enables "On days
|
||||
* of the week", value "daily"
|
||||
* enables "EveryX Days".
|
||||
* Only valid for type "daily".
|
||||
* @apiParam (Body) {String="daily","weekly","monthly","yearly"} [frequency=weekly] Values "weekly"
|
||||
* and "monthly" enable use of the "repeat" field.
|
||||
* All frequency values enable use of the "everyX" field.
|
||||
* Value "monthly" enables use of the "weeksOfMonth" and
|
||||
* "daysOfMonth" fields.
|
||||
* Frequency is only valid for type "daily".
|
||||
* @apiParam (Body) {String} [repeat=true] List of objects for days of the week, Days that
|
||||
* are true will be repeated upon. Only valid for type
|
||||
* "daily". Any days not specified will be marked as true.
|
||||
@@ -558,6 +572,10 @@ api.getTask = {
|
||||
* of days until this daily task is available again.
|
||||
* @apiParam (Body) {Number} [streak=0] Number of days that the task has consecutively
|
||||
* been checked off. Only valid for type "daily",
|
||||
* @apiParam (Body) {Integer[]} daysOfMonth Array of integers.
|
||||
* Only valid for type "daily"
|
||||
* @apiParam (Body) {Integer[]} weeksOfMonth Array of integers.
|
||||
* Only valid for type "daily"
|
||||
* @apiParam (Body) {Date} [startDate] Date when the task will first become available.
|
||||
* Only valid for type "daily".
|
||||
* @apiParam (Body) {Boolean} [up=true] Only valid for type "habit" If true, enables
|
||||
|
||||
Reference in New Issue
Block a user