0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/api/canary/membersStripeConnect.js
Fabien O'Carroll fc0e97593b Added membersStripeConnect controller auth method
no-issue

In order to issue a redirect we need access to the "raw" req/res
objects, which is why we must return the function which gets access to
them.

The members service is used to create the auth url and to update the
users session.
2020-06-02 15:28:42 +02:00

18 lines
681 B
JavaScript

const membersService = require('../../services/members');
module.exports = {
docName: 'members_stripe_connect',
auth: {
permissions: true,
query(frame) {
// This is something you have to do if you want to use the "framework" with access to the raw req/res
frame.response = async function (req, res) {
function setSessionProp(prop, val) {
req.session[prop] = val;
}
const stripeConnectAuthURL = await membersService.stripeConnect.getStripeConnectOAuthUrl(setSessionProp);
return res.redirect(stripeConnectAuthURL);
};
}
}
};