fix: local req missing url headers (#6126)
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
This commit is contained in:
@@ -51,7 +51,7 @@ const attachFakeURLProperties = (req: PayloadRequestWithData) => {
|
||||
// @ts-expect-error
|
||||
if (!req.origin) req.origin = getURLObject().origin
|
||||
// @ts-expect-error
|
||||
if (!req?.url) req.url = getURLObject().url
|
||||
if (!req?.url) req.url = getURLObject().href
|
||||
}
|
||||
|
||||
type CreateLocalReq = (
|
||||
@@ -84,6 +84,8 @@ export const createLocalReq: CreateLocalReq = async (
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
if (!req.headers) req.headers = new Headers()
|
||||
req.context = getRequestContext(req, context)
|
||||
req.payloadAPI = req?.payloadAPI || 'local'
|
||||
req.payload = payload
|
||||
|
||||
@@ -730,5 +730,25 @@ describe('Auth', () => {
|
||||
|
||||
expect(authenticated.token).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should forget and reset password', async () => {
|
||||
const forgot = await payload.forgotPassword({
|
||||
collection: 'users',
|
||||
data: {
|
||||
email: 'dev@payloadcms.com',
|
||||
},
|
||||
})
|
||||
|
||||
const reset = await payload.resetPassword({
|
||||
collection: 'users',
|
||||
overrideAccess: true,
|
||||
data: {
|
||||
password: 'test',
|
||||
token: forgot,
|
||||
},
|
||||
})
|
||||
|
||||
expect(reset.user.email).toStrictEqual('dev@payloadcms.com')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user