mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
Added alpha version of auto-login for Members
refs https://github.com/TryGhost/Team/issues/1067 This is the MVP for auto-login of Members, it does not support custom redirects, and will always just redirect to the same place that the signin & signup links do. Behind a feature flag whilst we iron out the functionality.
This commit is contained in:
parent
2c294be428
commit
81868c1850
1 changed files with 21 additions and 4 deletions
|
@ -193,12 +193,29 @@ module.exports = class RouterController {
|
|||
|
||||
const member = email ? await this._memberRepository.get({email}, {withRelated: ['stripeCustomers', 'products']}) : null;
|
||||
|
||||
let successUrl = req.body.successUrl || this._config.checkoutSuccessUrl;
|
||||
let cancelUrl = req.body.cancelUrl || this._config.checkoutCancelUrl;
|
||||
|
||||
if (this.labsService.isSet('membersAutoLogin')) {
|
||||
if (!member && req.body.customerEmail) {
|
||||
const memberExistsForCustomer = await this._memberRepository.get({email: req.body.customerEmail});
|
||||
if (!memberExistsForCustomer) {
|
||||
successUrl = await this._magicLinkService.getMagicLink({
|
||||
tokenData: {
|
||||
email: req.body.customerEmail
|
||||
},
|
||||
type: 'signup'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!member) {
|
||||
const customer = null;
|
||||
const session = await this._stripeAPIService.createCheckoutSession(priceId, customer, {
|
||||
coupon: couponId,
|
||||
successUrl: req.body.successUrl || this._config.checkoutSuccessUrl,
|
||||
cancelUrl: req.body.cancelUrl || this._config.checkoutCancelUrl,
|
||||
successUrl,
|
||||
cancelUrl,
|
||||
customerEmail: req.body.customerEmail,
|
||||
metadata: metadata
|
||||
});
|
||||
|
@ -242,8 +259,8 @@ module.exports = class RouterController {
|
|||
try {
|
||||
const session = await this._stripeAPIService.createCheckoutSession(priceId, stripeCustomer, {
|
||||
coupon: couponId,
|
||||
successUrl: req.body.successUrl || this._config.checkoutSuccessUrl,
|
||||
cancelUrl: req.body.cancelUrl || this._config.checkoutCancelUrl,
|
||||
successUrl,
|
||||
cancelUrl,
|
||||
metadata: metadata
|
||||
});
|
||||
const publicKey = this._stripeAPIService.getPublicKey();
|
||||
|
|
Loading…
Add table
Reference in a new issue