mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-25 02:31:59 -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;
|
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) {
|
if (!member) {
|
||||||
const customer = null;
|
const customer = null;
|
||||||
const session = await this._stripeAPIService.createCheckoutSession(priceId, customer, {
|
const session = await this._stripeAPIService.createCheckoutSession(priceId, customer, {
|
||||||
coupon: couponId,
|
coupon: couponId,
|
||||||
successUrl: req.body.successUrl || this._config.checkoutSuccessUrl,
|
successUrl,
|
||||||
cancelUrl: req.body.cancelUrl || this._config.checkoutCancelUrl,
|
cancelUrl,
|
||||||
customerEmail: req.body.customerEmail,
|
customerEmail: req.body.customerEmail,
|
||||||
metadata: metadata
|
metadata: metadata
|
||||||
});
|
});
|
||||||
|
@ -242,8 +259,8 @@ module.exports = class RouterController {
|
||||||
try {
|
try {
|
||||||
const session = await this._stripeAPIService.createCheckoutSession(priceId, stripeCustomer, {
|
const session = await this._stripeAPIService.createCheckoutSession(priceId, stripeCustomer, {
|
||||||
coupon: couponId,
|
coupon: couponId,
|
||||||
successUrl: req.body.successUrl || this._config.checkoutSuccessUrl,
|
successUrl,
|
||||||
cancelUrl: req.body.cancelUrl || this._config.checkoutCancelUrl,
|
cancelUrl,
|
||||||
metadata: metadata
|
metadata: metadata
|
||||||
});
|
});
|
||||||
const publicKey = this._stripeAPIService.getPublicKey();
|
const publicKey = this._stripeAPIService.getPublicKey();
|
||||||
|
|
Loading…
Add table
Reference in a new issue