chore(deps): update dependency prettier to v2.3.0 (#42074)
* chore(deps): update dependency prettier to v2.3.0 * chore: apply formating per prettier * fix: correctly disable import/no-unresolved Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Mrugesh Mohapatra <hi@mrugesh.dev> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -676,10 +676,8 @@ export default function initializeUser(User) {
|
||||
const updateData = { $set: {} };
|
||||
return this.getCompletedChallenges$()
|
||||
.flatMap(() => {
|
||||
const {
|
||||
updated,
|
||||
isNewCompletionCount
|
||||
} = buildCompletedChallengesUpdate(this.completedChallenges, project);
|
||||
const { updated, isNewCompletionCount } =
|
||||
buildCompletedChallengesUpdate(this.completedChallenges, project);
|
||||
updateData.$set.completedChallenges = updated;
|
||||
if (isNewCompletionCount) {
|
||||
let points = [];
|
||||
@ -830,12 +828,8 @@ export default function initializeUser(User) {
|
||||
if (!user) {
|
||||
return Observable.of({});
|
||||
}
|
||||
const {
|
||||
completedChallenges,
|
||||
progressTimestamps,
|
||||
timezone,
|
||||
profileUI
|
||||
} = user;
|
||||
const { completedChallenges, progressTimestamps, timezone, profileUI } =
|
||||
user;
|
||||
const allUser = {
|
||||
..._.pick(user, publicUserProps),
|
||||
isGithub: !!user.githubProfile,
|
||||
|
@ -97,57 +97,54 @@ export const devLoginRedirect = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export const createPassportCallbackAuthenticator = (strategy, config) => (
|
||||
req,
|
||||
res,
|
||||
next
|
||||
) => {
|
||||
return passport.authenticate(
|
||||
strategy,
|
||||
{ session: false },
|
||||
(err, user, userInfo) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
export const createPassportCallbackAuthenticator =
|
||||
(strategy, config) => (req, res, next) => {
|
||||
return passport.authenticate(
|
||||
strategy,
|
||||
{ session: false },
|
||||
(err, user, userInfo) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (!user || !userInfo) {
|
||||
return res.redirect('/signin');
|
||||
}
|
||||
if (!user || !userInfo) {
|
||||
return res.redirect('/signin');
|
||||
}
|
||||
|
||||
const { accessToken } = userInfo;
|
||||
const { provider } = config;
|
||||
if (accessToken && accessToken.id) {
|
||||
if (provider === 'auth0') {
|
||||
req.flash('success', 'flash.signin-success');
|
||||
} else if (user.email) {
|
||||
req.flash(
|
||||
'info',
|
||||
dedent`
|
||||
const { accessToken } = userInfo;
|
||||
const { provider } = config;
|
||||
if (accessToken && accessToken.id) {
|
||||
if (provider === 'auth0') {
|
||||
req.flash('success', 'flash.signin-success');
|
||||
} else if (user.email) {
|
||||
req.flash(
|
||||
'info',
|
||||
dedent`
|
||||
We are moving away from social authentication for privacy reasons. Next time
|
||||
we recommend using your email address: ${user.email} to sign in instead.
|
||||
`
|
||||
);
|
||||
);
|
||||
}
|
||||
setAccessTokenToResponse({ accessToken }, req, res);
|
||||
req.login(user);
|
||||
}
|
||||
|
||||
const state = req && req.query && req.query.state;
|
||||
// returnTo, origin and pathPrefix are audited by getReturnTo
|
||||
let { returnTo, origin, pathPrefix } = getReturnTo(state, jwtSecret);
|
||||
const redirectBase = getRedirectBase(origin, pathPrefix);
|
||||
|
||||
// TODO: getReturnTo could return a success flag to show a flash message,
|
||||
// but currently it immediately gets overwritten by a second message. We
|
||||
// should either change the message if the flag is present or allow
|
||||
// multiple messages to appear at once.
|
||||
|
||||
if (user.acceptedPrivacyTerms) {
|
||||
returnTo += isRootPath(redirectBase, returnTo) ? '/learn' : '';
|
||||
return res.redirectWithFlash(returnTo);
|
||||
} else {
|
||||
return res.redirectWithFlash(`${redirectBase}/email-sign-up`);
|
||||
}
|
||||
setAccessTokenToResponse({ accessToken }, req, res);
|
||||
req.login(user);
|
||||
}
|
||||
|
||||
const state = req && req.query && req.query.state;
|
||||
// returnTo, origin and pathPrefix are audited by getReturnTo
|
||||
let { returnTo, origin, pathPrefix } = getReturnTo(state, jwtSecret);
|
||||
const redirectBase = getRedirectBase(origin, pathPrefix);
|
||||
|
||||
// TODO: getReturnTo could return a success flag to show a flash message,
|
||||
// but currently it immediately gets overwritten by a second message. We
|
||||
// should either change the message if the flag is present or allow
|
||||
// multiple messages to appear at once.
|
||||
|
||||
if (user.acceptedPrivacyTerms) {
|
||||
returnTo += isRootPath(redirectBase, returnTo) ? '/learn' : '';
|
||||
return res.redirectWithFlash(returnTo);
|
||||
} else {
|
||||
return res.redirectWithFlash(`${redirectBase}/email-sign-up`);
|
||||
}
|
||||
}
|
||||
)(req, res, next);
|
||||
};
|
||||
)(req, res, next);
|
||||
};
|
||||
|
@ -53,14 +53,12 @@ export const mockCancellationHook = {
|
||||
},
|
||||
links: [
|
||||
{
|
||||
href:
|
||||
'https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-1VF24938EU372274X-83540367M0110254R',
|
||||
href: 'https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-1VF24938EU372274X-83540367M0110254R',
|
||||
rel: 'self',
|
||||
method: 'GET'
|
||||
},
|
||||
{
|
||||
href:
|
||||
'https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-1VF24938EU372274X-83540367M0110254R/resend',
|
||||
href: 'https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-1VF24938EU372274X-83540367M0110254R/resend',
|
||||
rel: 'resend',
|
||||
method: 'POST'
|
||||
}
|
||||
@ -156,32 +154,27 @@ export const mockActivationHook = {
|
||||
},
|
||||
links: [
|
||||
{
|
||||
href:
|
||||
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G',
|
||||
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G',
|
||||
rel: 'self',
|
||||
method: 'GET'
|
||||
},
|
||||
{
|
||||
href:
|
||||
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G',
|
||||
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G',
|
||||
rel: 'edit',
|
||||
method: 'PATCH'
|
||||
},
|
||||
{
|
||||
href:
|
||||
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/suspend',
|
||||
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/suspend',
|
||||
rel: 'suspend',
|
||||
method: 'POST'
|
||||
},
|
||||
{
|
||||
href:
|
||||
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/cancel',
|
||||
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/cancel',
|
||||
rel: 'cancel',
|
||||
method: 'POST'
|
||||
},
|
||||
{
|
||||
href:
|
||||
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/capture',
|
||||
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/capture',
|
||||
rel: 'capture',
|
||||
method: 'POST'
|
||||
}
|
||||
@ -194,15 +187,13 @@ export const mockActivationHook = {
|
||||
},
|
||||
links: [
|
||||
{
|
||||
href:
|
||||
'https://api.paypal.com/v1/notifications/webhooks-events/WH-77687562XN25889J8-8Y6T55435R66168T6',
|
||||
href: 'https://api.paypal.com/v1/notifications/webhooks-events/WH-77687562XN25889J8-8Y6T55435R66168T6',
|
||||
rel: 'self',
|
||||
method: 'GET',
|
||||
encType: 'application/json'
|
||||
},
|
||||
{
|
||||
href:
|
||||
'https://api.paypal.com/v1/notifications/webhooks-events/WH-77687562XN25889J8-8Y6T55435R66168T6/resend',
|
||||
href: 'https://api.paypal.com/v1/notifications/webhooks-events/WH-77687562XN25889J8-8Y6T55435R66168T6/resend',
|
||||
rel: 'resend',
|
||||
method: 'POST',
|
||||
encType: 'application/json'
|
||||
|
@ -17,11 +17,13 @@ export function wrapHandledError(
|
||||
}
|
||||
|
||||
// for use with express-validator error formatter
|
||||
export const createValidatorErrorFormatter = (type, redirectTo) => ({ msg }) =>
|
||||
wrapHandledError(new Error(msg), {
|
||||
type,
|
||||
message: msg,
|
||||
redirectTo,
|
||||
// we default to 400 as these are malformed requests
|
||||
status: 400
|
||||
});
|
||||
export const createValidatorErrorFormatter =
|
||||
(type, redirectTo) =>
|
||||
({ msg }) =>
|
||||
wrapHandledError(new Error(msg), {
|
||||
type,
|
||||
message: msg,
|
||||
redirectTo,
|
||||
// we default to 400 as these are malformed requests
|
||||
status: 400
|
||||
});
|
||||
|
@ -24,10 +24,8 @@ jest.mock('axios');
|
||||
|
||||
const verificationUrl = `https://api.sandbox.paypal.com/v1/notifications/verify-webhook-signature`;
|
||||
const tokenUrl = `https://api.sandbox.paypal.com/v1/oauth2/token`;
|
||||
const {
|
||||
body: activationHookBody,
|
||||
headers: activationHookHeaders
|
||||
} = mockActivationHook;
|
||||
const { body: activationHookBody, headers: activationHookHeaders } =
|
||||
mockActivationHook;
|
||||
|
||||
describe('donation', () => {
|
||||
describe('getAsyncPaypalToken', () => {
|
||||
|
@ -78,15 +78,17 @@ export function ifUserRedirectTo(status) {
|
||||
}
|
||||
|
||||
// for use with express-validator error formatter
|
||||
export const createValidatorErrorHandler = (...args) => (req, res, next) => {
|
||||
const validation = validationResult(req).formatWith(
|
||||
createValidatorErrorFormatter(...args)
|
||||
);
|
||||
export const createValidatorErrorHandler =
|
||||
(...args) =>
|
||||
(req, res, next) => {
|
||||
const validation = validationResult(req).formatWith(
|
||||
createValidatorErrorFormatter(...args)
|
||||
);
|
||||
|
||||
if (!validation.isEmpty()) {
|
||||
const errors = validation.array();
|
||||
return next(errors.pop());
|
||||
}
|
||||
if (!validation.isEmpty()) {
|
||||
const errors = validation.array();
|
||||
return next(errors.pop());
|
||||
}
|
||||
|
||||
return next();
|
||||
};
|
||||
return next();
|
||||
};
|
||||
|
Reference in New Issue
Block a user