[WEB-2729] chore: updated live server auth cookies handling (#5913)

* chore: updated live server auth cookies handling

* chore: update token parsing logic

* fix: types and better logical seperation between the existing two tokens

* fix: better fallback to use request headers for cookies

---------

Co-authored-by: Palanikannan M <akashmalinimurugu@gmail.com>
This commit is contained in:
Lakhan Baheti 2024-10-30 17:38:29 +05:30 committed by GitHub
parent 403482fa6e
commit 8ea34b5995
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 54 additions and 33 deletions

View file

@ -7,11 +7,11 @@ const userService = new UserService();
type Props = {
cookie: string;
token: string;
userId: string;
};
export const handleAuthentication = async (props: Props) => {
const { cookie, token } = props;
const { cookie, userId } = props;
// fetch current user info
let response;
try {
@ -20,7 +20,7 @@ export const handleAuthentication = async (props: Props) => {
manualLogger.error("Failed to fetch current user:", error);
throw error;
}
if (response.id !== token) {
if (response.id !== userId) {
throw Error("Authentication failed: Token doesn't match the current user.");
}