fix redirect error encoding

Signed-off-by: Stephen Glass <stephen@stephen.glass>
This commit is contained in:
Stephen Glass
2024-10-08 09:25:02 -04:00
parent c05743e94f
commit 5e5e4a850c
4 changed files with 4 additions and 9 deletions
@@ -167,7 +167,7 @@ export const SingleSignInPage = ({
useMountEffect(() => {
if (errorParam) {
setError(new Error(decodeURIComponent(errorParam)));
setError(new Error(errorParam));
}
login({ checkExisting: true });
});
@@ -101,10 +101,7 @@ export const useSignInProviders = (
const errorParam = searchParams.get('error');
if (errorParam) {
errorApi.post(
new ForwardedError(t('signIn.loginFailed'), {
name: 'Error',
message: decodeURIComponent(errorParam),
}),
new ForwardedError(t('signIn.loginFailed'), new Error(errorParam)),
);
}
});
@@ -768,9 +768,7 @@ describe('createOAuthRouteHandlers', () => {
// Verify that the 'error' search param is set with the encoded error message
const errorMessage = redirectUrl.searchParams.get('error');
expect(errorMessage).toBe(
encodeURIComponent('Auth response is missing cookie nonce'),
);
expect(errorMessage).toBe('Auth response is missing cookie nonce');
});
});
});
@@ -252,7 +252,7 @@ export function createOAuthRouteHandlers<TProfile>(
if (state?.flow === 'redirect' && state?.redirectUrl) {
const redirectUrl = new URL(state.redirectUrl);
redirectUrl.searchParams.set('error', encodeURIComponent(message));
redirectUrl.searchParams.set('error', message);
// set the error in a cookie and redirect user back to sign in where the error can be rendered
res.redirect(redirectUrl.toString());