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:
parent
c4f3d44baa
commit
379f64428e
8 changed files with 22 additions and 22 deletions
|
@ -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}
|
||||
|
|
|
@ -51,7 +51,7 @@ const session = {
|
|||
|
||||
if (err.errorType === 'PasswordResetRequiredError') {
|
||||
await api.authentication.generateResetToken({
|
||||
passwordreset: [{
|
||||
password_reset: [{
|
||||
email: object.username
|
||||
}]
|
||||
}, frame.options.context);
|
||||
|
|
|
@ -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)
|
||||
}]
|
||||
};
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/* eslint-disable max-lines */
|
||||
|
||||
module.exports = {
|
||||
get passwordreset() {
|
||||
return require('./passwordreset');
|
||||
get password_reset() {
|
||||
return require('./password_reset');
|
||||
},
|
||||
|
||||
get setup() {
|
||||
|
|
|
@ -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({
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
}]
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue