mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
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.
This commit is contained in:
parent
5b058d6d5b
commit
fc0e97593b
@ -71,6 +71,10 @@ module.exports = {
|
||||
return shared.pipeline(require('./settings'), localUtils);
|
||||
},
|
||||
|
||||
get membersStripeConnect() {
|
||||
return shared.pipeline(require('./membersStripeConnect'), localUtils);
|
||||
},
|
||||
|
||||
get members() {
|
||||
return shared.pipeline(require('./members'), localUtils);
|
||||
},
|
||||
|
18
core/server/api/canary/membersStripeConnect.js
Normal file
18
core/server/api/canary/membersStripeConnect.js
Normal file
@ -0,0 +1,18 @@
|
||||
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);
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
@ -97,6 +97,8 @@ module.exports = function apiRoutes() {
|
||||
http(apiCanary.members.importCSV)
|
||||
);
|
||||
|
||||
router.get('/members/stripe_connect', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.membersStripeConnect.auth));
|
||||
|
||||
router.get('/members/:id', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.read));
|
||||
router.put('/members/:id', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.edit));
|
||||
router.del('/members/:id', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.destroy));
|
||||
|
Loading…
Reference in New Issue
Block a user