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
29 lines
985 B
Plaintext
29 lines
985 B
Plaintext
import { generatePayloadCookie, isolateObjectProperty, loginOperation } from 'payload';
|
|
export function login(collection) {
|
|
async function resolver(_, args, context) {
|
|
const options = {
|
|
collection,
|
|
data: {
|
|
email: args.email,
|
|
password: args.password,
|
|
username: args.username
|
|
},
|
|
depth: 0,
|
|
req: isolateObjectProperty(context.req, 'transactionID')
|
|
};
|
|
const result = await loginOperation(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=login.js.map |