0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Renamed passwordreset body object to password_reset

refs https://github.com/TryGhost/Toolbox/issues/308

- I've just renamed the `/authentication/passwordreset` API endpoint to
  `/authentication/password_reset` and noticed the body object is also
  badly named
- this clears that up in code and tests
This commit is contained in:
Daniel Lockyer 2022-04-25 16:46:47 +01:00
parent c4f3d44baa
commit 379f64428e
No known key found for this signature in database
GPG key ID: D21186F0B47295AD
8 changed files with 22 additions and 22 deletions

View file

@ -129,7 +129,7 @@ module.exports = {
generateResetToken: {
validation: {
docName: 'passwordreset'
docName: 'password_reset'
},
permissions: true,
options: [
@ -141,7 +141,7 @@ module.exports = {
return auth.setup.assertSetupCompleted(true)();
})
.then(() => {
return auth.passwordreset.generateToken(frame.data.passwordreset[0].email, api.settings);
return auth.passwordreset.generateToken(frame.data.password_reset[0].email, api.settings);
})
.then((token) => {
return auth.passwordreset.sendResetNotification(token, api.mail);
@ -151,7 +151,7 @@ module.exports = {
resetPassword: {
validation: {
docName: 'passwordreset',
docName: 'password_reset',
data: {
newPassword: {required: true},
ne2Password: {required: true}

View file

@ -51,7 +51,7 @@ const session = {
if (err.errorType === 'PasswordResetRequiredError') {
await api.authentication.generateResetToken({
passwordreset: [{
password_reset: [{
email: object.username
}]
}, frame.options.context);

View file

@ -33,7 +33,7 @@ module.exports = {
generateResetToken(data, apiConfig, frame) {
frame.response = {
passwordreset: [{
password_reset: [{
message: tpl(messages.checkEmailForInstructions)
}]
};
@ -41,7 +41,7 @@ module.exports = {
resetPassword(data, apiConfig, frame) {
frame.response = {
passwordreset: [{
password_reset: [{
message: tpl(messages.passwordChanged)
}]
};

View file

@ -5,8 +5,8 @@
/* eslint-disable max-lines */
module.exports = {
get passwordreset() {
return require('./passwordreset');
get password_reset() {
return require('./password_reset');
},
get setup() {

View file

@ -13,7 +13,7 @@ module.exports = {
resetPassword(apiConfig, frame) {
debug('resetPassword');
const data = frame.data.passwordreset[0];
const data = frame.data.password_reset[0];
if (data.newPassword !== data.ne2Password) {
return Promise.reject(new errors.ValidationError({
@ -25,7 +25,7 @@ module.exports = {
generateResetToken(apiConfig, frame) {
debug('generateResetToken');
const email = frame.data.passwordreset[0].email;
const email = frame.data.password_reset[0].email;
if (typeof email !== 'string' || !validator.isEmail(email)) {
throw new errors.BadRequestError({

View file

@ -61,10 +61,10 @@ function generateToken(email, settingsAPI, transaction) {
}
function extractTokenParts(options) {
options.data.passwordreset[0].token = security.url.decodeBase64(options.data.passwordreset[0].token);
options.data.password_reset[0].token = security.url.decodeBase64(options.data.password_reset[0].token);
const tokenParts = security.tokens.resetToken.extract({
token: options.data.passwordreset[0].token
token: options.data.password_reset[0].token
});
if (!tokenParts) {
@ -93,7 +93,7 @@ function protectBruteForce({options, tokenParts}) {
function doReset(options, tokenParts, settingsAPI) {
let dbHash;
const data = options.data.passwordreset[0];
const data = options.data.password_reset[0];
const resetToken = data.token;
const oldPassword = data.oldPassword;
const newPassword = data.newPassword;

View file

@ -320,7 +320,7 @@ Object {
exports[`Authentication API Password reset reset password 1: [body] 1`] = `
Object {
"passwordreset": Array [
"password_reset": Array [
Object {
"message": "Password changed successfully.",
},
@ -332,7 +332,7 @@ exports[`Authentication API Password reset reset password 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "64",
"content-length": "65",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding",
@ -371,7 +371,7 @@ Object {
exports[`Authentication API Password reset reset password: generate reset token 1: [body] 1`] = `
Object {
"passwordreset": Array [
"password_reset": Array [
Object {
"message": "Check your email for further instructions.",
},
@ -383,7 +383,7 @@ exports[`Authentication API Password reset reset password: generate reset token
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "76",
"content-length": "77",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding",

View file

@ -350,7 +350,7 @@ describe('Authentication API', function () {
await agent.put('authentication/password_reset')
.header('Accept', 'application/json')
.body({
passwordreset: [{
password_reset: [{
token: token,
newPassword: 'thisissupersafe',
ne2Password: 'thisissupersafe'
@ -368,7 +368,7 @@ describe('Authentication API', function () {
.put('authentication/password_reset')
.header('Accept', 'application/json')
.body({
passwordreset: [{
password_reset: [{
token: 'invalid',
newPassword: 'thisissupersafe',
ne2Password: 'thisissupersafe'
@ -400,7 +400,7 @@ describe('Authentication API', function () {
.put('authentication/password_reset')
.header('Accept', 'application/json')
.body({
passwordreset: [{
password_reset: [{
token: token,
newPassword: 'thisissupersafe',
ne2Password: 'thisissupersafe'
@ -429,7 +429,7 @@ describe('Authentication API', function () {
.put('authentication/password_reset')
.header('Accept', 'application/json')
.body({
passwordreset: [{
password_reset: [{
token: token,
newPassword: 'thisissupersafe',
ne2Password: 'thisissupersafe'
@ -451,7 +451,7 @@ describe('Authentication API', function () {
.post('authentication/password_reset')
.header('Accept', 'application/json')
.body({
passwordreset: [{
password_reset: [{
email: email
}]
})