Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
32 lines
1.1 KiB
Plaintext
32 lines
1.1 KiB
Plaintext
import { generatePayloadCookie, isolateObjectProperty, resetPasswordOperation } from 'payload';
|
|
export function resetPassword(collection) {
|
|
async function resolver(_, args, context) {
|
|
if (args.locale) {
|
|
context.req.locale = args.locale;
|
|
}
|
|
if (args.fallbackLocale) {
|
|
context.req.fallbackLocale = args.fallbackLocale;
|
|
}
|
|
const options = {
|
|
api: 'GraphQL',
|
|
collection,
|
|
data: args,
|
|
depth: 0,
|
|
req: isolateObjectProperty(context.req, 'transactionID')
|
|
};
|
|
const result = await resetPasswordOperation(options);
|
|
const cookie = generatePayloadCookie({
|
|
collectionAuthConfig: collection.config.auth,
|
|
cookiePrefix: context.req.payload.config.cookiePrefix,
|
|
token: result.token
|
|
});
|
|
context.headers['Set-Cookie'] = cookie;
|
|
if (collection.config.auth.removeTokenFromResponses) {
|
|
delete result.token;
|
|
}
|
|
return result;
|
|
}
|
|
return resolver;
|
|
}
|
|
|
|
//# sourceMappingURL=resetPassword.js.map |