mirror of
https://github.com/strapi/strapi.git
synced 2025-09-03 22:03:08 +00:00
Remove password and token from fetchable data USER API / AUTH
This commit is contained in:
parent
8ab44d86af
commit
15e4f9985f
@ -14,7 +14,7 @@ import { findIndex, get, isBoolean, isEmpty, map, replace } from 'lodash';
|
|||||||
import cn from 'classnames';
|
import cn from 'classnames';
|
||||||
|
|
||||||
// Logo
|
// Logo
|
||||||
import LogoStrapi from 'assets/images/logo.svg';
|
import LogoStrapi from 'assets/images/logo_strapi.png';
|
||||||
|
|
||||||
// Design
|
// Design
|
||||||
import Button from 'components/Button';
|
import Button from 'components/Button';
|
||||||
|
@ -174,6 +174,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
|
"identity": {
|
||||||
|
"enabled": true,
|
||||||
|
"policy": ""
|
||||||
|
},
|
||||||
"find": {
|
"find": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"policy": ""
|
"policy": ""
|
||||||
@ -193,10 +197,6 @@
|
|||||||
"destroy": {
|
"destroy": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"policy": ""
|
"policy": ""
|
||||||
},
|
|
||||||
"identity": {
|
|
||||||
"enabled": true,
|
|
||||||
"policy": ""
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"userspermissions": {
|
"userspermissions": {
|
||||||
@ -430,11 +430,15 @@
|
|||||||
"policy": ""
|
"policy": ""
|
||||||
},
|
},
|
||||||
"changePassword": {
|
"changePassword": {
|
||||||
"enabled": true,
|
"enabled": false,
|
||||||
"policy": ""
|
"policy": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
|
"identity": {
|
||||||
|
"enabled": false,
|
||||||
|
"policy": ""
|
||||||
|
},
|
||||||
"find": {
|
"find": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"policy": ""
|
"policy": ""
|
||||||
@ -454,10 +458,6 @@
|
|||||||
"destroy": {
|
"destroy": {
|
||||||
"enabled": false,
|
"enabled": false,
|
||||||
"policy": ""
|
"policy": ""
|
||||||
},
|
|
||||||
"identity": {
|
|
||||||
"enabled": false,
|
|
||||||
"policy": ""
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"userspermissions": {
|
"userspermissions": {
|
||||||
|
@ -57,7 +57,7 @@ module.exports = {
|
|||||||
} else {
|
} else {
|
||||||
ctx.send({
|
ctx.send({
|
||||||
jwt: strapi.plugins['users-permissions'].services.jwt.issue(user),
|
jwt: strapi.plugins['users-permissions'].services.jwt.issue(user),
|
||||||
user: user
|
user: _.omit(user.toJSON(), ['password', 'resetPasswordToken'])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -100,7 +100,7 @@ module.exports = {
|
|||||||
|
|
||||||
ctx.send({
|
ctx.send({
|
||||||
jwt: strapi.plugins['users-permissions'].services.jwt.issue(user),
|
jwt: strapi.plugins['users-permissions'].services.jwt.issue(user),
|
||||||
user: user
|
user: _.omit(user.toJSON(), ['password', 'resetPasswordToken'])
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ module.exports = {
|
|||||||
|
|
||||||
ctx.send({
|
ctx.send({
|
||||||
jwt: strapi.plugins['users-permissions'].services.jwt.issue(user),
|
jwt: strapi.plugins['users-permissions'].services.jwt.issue(user),
|
||||||
user: user
|
user: _.omit(user.toJSON(), ['password', 'resetPasswordToken'])
|
||||||
});
|
});
|
||||||
} else if (params.password && params.passwordConfirmation && params.password !== params.passwordConfirmation) {
|
} else if (params.password && params.passwordConfirmation && params.password !== params.passwordConfirmation) {
|
||||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.password.matching' }] }] : 'Passwords do not match.');
|
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.password.matching' }] }] : 'Passwords do not match.');
|
||||||
|
@ -17,20 +17,32 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
find: async (ctx) => {
|
find: async (ctx) => {
|
||||||
const data = await strapi.plugins['users-permissions'].services.user.fetchAll(ctx.query);
|
let data = await strapi.plugins['users-permissions'].services.user.fetchAll(ctx.query);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
data = _.reduce(data, (acc, user) => {
|
||||||
|
acc.push(_.omit(user.toJSON(), ['password', 'resetPasswordToken']));
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
|
||||||
// Send 200 `ok`
|
// Send 200 `ok`
|
||||||
ctx.send(data);
|
ctx.send(data);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
}
|
||||||
* Retrieve a user record.
|
* Retrieve a user record.
|
||||||
*
|
*
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
findOne: async (ctx) => {
|
findOne: async (ctx) => {
|
||||||
const data = await strapi.plugins['users-permissions'].services.user.fetch(ctx.params);
|
let data = await strapi.plugins['users-permissions'].services.user.fetch(ctx.params);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
data = _.omit(data.toJSON(), ['password', 'resetPasswordToken']);
|
||||||
|
}
|
||||||
|
|
||||||
// Send 200 `ok`
|
// Send 200 `ok`
|
||||||
ctx.send(data);
|
ctx.send(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user