mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Merge branch 'develop' of https://github.com/HabitRPG/habitica into autocomplete-username
# Conflicts: # package.json # website/client/components/chat/autoComplete.vue # website/client/components/chat/chatCard.vue # website/client/components/groups/chat.vue # website/server/controllers/api-v3/chat.js # website/server/controllers/api-v3/members.js # website/server/controllers/api-v4/members.js
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
BadRequest,
|
||||
} from '../../libs/errors';
|
||||
import * as passwordUtils from '../../libs/password';
|
||||
import { send as sendEmail } from '../../libs/email';
|
||||
import { sendTxn as sendTxnEmail } from '../../libs/email';
|
||||
import { validatePasswordResetCodeAndFindUser, convertToBcrypt} from '../../libs/password';
|
||||
import { encrypt } from '../../libs/encryption';
|
||||
import {
|
||||
@@ -98,6 +98,9 @@ api.loginLocal = {
|
||||
// load the entire user because we may have to save it to convert the password to bcrypt
|
||||
let user = await User.findOne(login).exec();
|
||||
|
||||
// if user is using social login, then user will not have a hashed_password stored
|
||||
if (!user || !user.auth.local.hashed_password) throw new NotAuthorized(res.t('invalidLoginCredentialsLong'));
|
||||
|
||||
let isValidPassword;
|
||||
|
||||
if (!user) {
|
||||
@@ -201,6 +204,8 @@ api.updateUsername = {
|
||||
} else {
|
||||
user.items.pets['Wolf-Veteran'] = 5;
|
||||
}
|
||||
|
||||
user.markModified('items.pets');
|
||||
}
|
||||
await user.save();
|
||||
|
||||
@@ -298,19 +303,9 @@ api.resetPassword = {
|
||||
|
||||
user.auth.local.passwordResetCode = passwordResetCode;
|
||||
|
||||
sendEmail({
|
||||
from: 'Habitica <admin@habitica.com>',
|
||||
to: email,
|
||||
subject: res.t('passwordResetEmailSubject'),
|
||||
text: res.t('passwordResetEmailText', {
|
||||
username: user.auth.local.username,
|
||||
passwordResetLink: link,
|
||||
}),
|
||||
html: res.t('passwordResetEmailHtml', {
|
||||
username: user.auth.local.username,
|
||||
passwordResetLink: link,
|
||||
}),
|
||||
});
|
||||
sendTxnEmail(user, 'reset-password', [
|
||||
{name: 'PASSWORD_RESET_LINK', content: link},
|
||||
]);
|
||||
|
||||
await user.save();
|
||||
} else {
|
||||
@@ -369,7 +364,7 @@ api.updateEmail = {
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /api/v3/user/auth/reset-password-set-new-one Reser Password Set New one
|
||||
* @api {post} /api/v3/user/auth/reset-password-set-new-one Reset Password Set New one
|
||||
* @apiDescription Set a new password for a user that reset theirs. Not meant for public usage.
|
||||
* @apiName ResetPasswordSetNewOne
|
||||
* @apiGroup User
|
||||
|
||||
Reference in New Issue
Block a user