Skip to content

Commit

Permalink
fix: auth store strategies (adrien2p#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p authored Nov 16, 2022
1 parent 57213ec commit 60a03e6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export function loadFacebookStoreStrategy(
accessToken: string,
refreshToken: string,
profile: { emails: { value: string }[]; name?: { givenName?: string; familyName?: string } },
done: (err: null | unknown, data: null | { id: string }) => void
done: (err: null | unknown, data: null | { customer_id: string }) => void
) {
const done_ = (err: null | unknown, data: null | { id: string }) => {
done(err, data);
done(err, { customer_id: data.id });
};

await verifyCallbackFn(container, req, accessToken, refreshToken, profile, done_);
Expand Down Expand Up @@ -85,7 +85,7 @@ export function getFacebookStoreAuthRouter(facebook: FacebookAuthOptions, config
session: false,
}),
(req, res) => {
const token = jwt.sign({ userId: req.user.id }, configModule.projectConfig.jwt_secret, {
const token = jwt.sign({ userId: req.user.customer_id }, configModule.projectConfig.jwt_secret, {
expiresIn: facebook.store.expiresIn ?? TWENTY_FOUR_HOURS_IN_MS,
});
res.cookie(AUTH_TOKEN_COOKIE_NAME, token, getCookieOptions()).redirect(facebook.store.successRedirect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export function loadGoogleStoreStrategy(
accessToken: string,
refreshToken: string,
profile: { emails: { value: string }[]; name?: { givenName?: string; familyName?: string } },
done: (err: null | unknown, data: null | { id: string }) => void
done: (err: null | unknown, data: null | { customer_id: string }) => void
) {
const done_ = (err: null | unknown, data: null | { id: string }) => {
done(err, data);
done(err, { customer_id: data.id });
};

await verifyCallbackFn(container, req, accessToken, refreshToken, profile, done_);
Expand Down Expand Up @@ -88,7 +88,7 @@ export function getGoogleStoreAuthRouter(google: GoogleAuthOptions, configModule
session: false,
}),
(req, res) => {
const token = jwt.sign({ userId: req.user.id }, configModule.projectConfig.jwt_secret, {
const token = jwt.sign({ userId: req.user.customer_id }, configModule.projectConfig.jwt_secret, {
expiresIn: google.store.expiresIn ?? TWENTY_FOUR_HOURS_IN_MS,
});
res.cookie(AUTH_TOKEN_COOKIE_NAME, token, getCookieOptions()).redirect(google.store.successRedirect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export function loadLinkedinStoreStrategy(
accessToken: string,
refreshToken: string,
profile: { emails: { value: string }[]; name?: { givenName?: string; familyName?: string } },
done: (err: null | unknown, data: null | { id: string }) => void
done: (err: null | unknown, data: null | { customer_id: string }) => void
) {
const done_ = (err: null | unknown, data: null | { id: string }) => {
done(err, data);
done(err, { customer_id: data.id });
};

await verifyCallbackFn(container, req, accessToken, refreshToken, profile, done_);
Expand Down Expand Up @@ -90,7 +90,7 @@ export function getLinkedinStoreAuthRouter(linkedin: LinkedinAuthOptions, config
session: false,
}),
(req, res) => {
const token = jwt.sign({ userId: req.user.id }, configModule.projectConfig.jwt_secret, {
const token = jwt.sign({ userId: req.user.customer_id }, configModule.projectConfig.jwt_secret, {
expiresIn: linkedin.store.expiresIn ?? TWENTY_FOUR_HOURS_IN_MS,
});
res.cookie(AUTH_TOKEN_COOKIE_NAME, token, getCookieOptions()).redirect(linkedin.store.successRedirect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export function loadTwitterStoreStrategy(
accessToken: string,
refreshToken: string,
profile: { emails: { value: string }[]; name?: { givenName?: string; familyName?: string } },
done: (err: null | unknown, data: null | { id: string }) => void
done: (err: null | unknown, data: null | { customer_id: string }) => void
) {
const done_ = (err: null | unknown, data: null | { id: string }) => {
done(err, data);
done(err, { customer_id: data.id });
};

await verifyCallbackFn(container, req, accessToken, refreshToken, profile, done_);
Expand Down Expand Up @@ -91,7 +91,7 @@ export function getTwitterStoreAuthRouter(twitter: TwitterAuthOptions, configMod
session: false,
}),
(req, res) => {
const token = jwt.sign({ userId: req.user.id }, configModule.projectConfig.jwt_secret, {
const token = jwt.sign({ userId: req.user.customer_id }, configModule.projectConfig.jwt_secret, {
expiresIn: twitter.store.expiresIn ?? TWENTY_FOUR_HOURS_IN_MS,
});
res.cookie(AUTH_TOKEN_COOKIE_NAME, token, getCookieOptions()).redirect(twitter.store.successRedirect);
Expand Down

0 comments on commit 60a03e6

Please sign in to comment.