Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: double passkey authent when accessing connexion & account page w… #711

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/controllers/webauthn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export const postVerifyAuthenticationController =
? getUserFromAuthenticatedSession(req).email
: getEmailFromUnauthenticatedSession(req);

const { user, userVerified } = await verifyAuthentication({
let { user, userVerified } = await verifyAuthentication({
email,
response,
isSecondFactorVerification,
Expand All @@ -206,7 +206,7 @@ export const postVerifyAuthenticationController =
if (isSecondFactorVerification) {
addAuthenticationMethodReferenceInSession(req, res, user, "pop");
} else {
await createAuthenticatedSession(req, res, user, "pop");
user = await createAuthenticatedSession(req, res, user, "pop");
}

if (userVerified) {
Expand Down
7 changes: 4 additions & 3 deletions src/managers/session/authenticated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const createAuthenticatedSession = async (
res: Response,
user: User,
authenticationMethodReference: AmrValue,
): Promise<null> => {
): Promise<User> => {
// we store old session value to pass it to the new logged-in session
// email and needsInclusionconnectWelcomePage are not passed to the new session as it is not useful within logged session
// csrfToken should not be passed to the new session for security reasons
Expand All @@ -66,10 +66,11 @@ export const createAuthenticatedSession = async (
if (err) {
reject(err);
} else {
req.session.user = await update(user.id, {
const updatedUser = await update(user.id, {
sign_in_count: user.sign_in_count + 1,
last_sign_in_at: new Date(),
});
req.session.user = updatedUser;
// we restore previous session navigation values
req.session.interactionId = interactionId;
req.session.mustReturnOneOrganizationInPayload =
Expand All @@ -93,7 +94,7 @@ export const createAuthenticatedSession = async (
setIsTrustedBrowserFromLoggedInSession(req);
}

resolve(null);
resolve(updatedUser);
}
});
});
Expand Down