fix graphql forgot password
This commit is contained in:
@@ -13,12 +13,8 @@ const registerUpload = require('../uploads/graphql/register');
|
||||
const buildWhereInputType = require('./schema/buildWhereInputType');
|
||||
|
||||
class GraphQL {
|
||||
constructor(config, collections, User, Upload, globals) {
|
||||
this.config = config;
|
||||
this.User = User;
|
||||
this.Upload = Upload;
|
||||
this.collections = collections;
|
||||
this.globals = globals;
|
||||
constructor(init) {
|
||||
Object.assign(this, init);
|
||||
this.init = this.init.bind(this);
|
||||
|
||||
this.types = {
|
||||
|
||||
@@ -60,7 +60,7 @@ class Payload {
|
||||
identifyAPI('GraphQL'),
|
||||
createAuthHeaderFromCookie,
|
||||
authenticate,
|
||||
new GraphQL(this.config, this.collections, this.User, this.Upload, this.globals).init(),
|
||||
new GraphQL(this).init(),
|
||||
);
|
||||
|
||||
this.router.get(this.config.routes.graphQLPlayground, graphQLPlayground({
|
||||
|
||||
@@ -168,7 +168,7 @@ function registerUser() {
|
||||
args: {
|
||||
[useAsUsername]: { type: new GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: forgotPassword(this.User, this.email),
|
||||
resolve: forgotPassword(this.config, this.User.Model, this.sendEmail),
|
||||
};
|
||||
|
||||
this.Mutation.fields.resetPassword = {
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
/* eslint-disable no-param-reassign */
|
||||
const { forgotPassword } = require('../../operations');
|
||||
|
||||
const forgotPasswordResolver = (config, email) => async (_, args, context) => {
|
||||
const forgotPasswordResolver = (config, Model, email) => async (_, args, context) => {
|
||||
const options = {
|
||||
config,
|
||||
Model,
|
||||
data: args,
|
||||
email,
|
||||
req: context,
|
||||
};
|
||||
|
||||
const result = await forgotPassword(options);
|
||||
await forgotPassword(options);
|
||||
|
||||
return result;
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = forgotPasswordResolver;
|
||||
|
||||
@@ -67,12 +67,6 @@ const forgotPassword = async (args) => {
|
||||
if (typeof afterForgotPasswordHook === 'function') {
|
||||
await afterForgotPasswordHook(options);
|
||||
}
|
||||
|
||||
// /////////////////////////////////////
|
||||
// 4. Return
|
||||
// /////////////////////////////////////
|
||||
|
||||
return;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,17 @@ const sanitizeUserCollection = (userConfig) => {
|
||||
|
||||
sanitizedUserConfig.fields = sanitizeFields(userConfig.fields);
|
||||
|
||||
// /////////////////////////////////
|
||||
// Hidden fields
|
||||
// /////////////////////////////////
|
||||
|
||||
const hiddenFields = Array.isArray(sanitizedUserConfig.hidden) ? sanitizedUserConfig.hidden : [];
|
||||
sanitizedUserConfig.hidden = [
|
||||
...hiddenFields,
|
||||
'resetPasswordToken',
|
||||
'resetPasswordExpiration',
|
||||
];
|
||||
|
||||
return sanitizedUserConfig;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user