mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-04 06:18:34 +00:00
UBERF-9526 Fix order of token locations in services (#8101)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
669ea11d03
commit
d442787574
@ -35,7 +35,7 @@ const extractAuthorizationToken = (authorization?: string): Token | null => {
|
|||||||
|
|
||||||
export function extractToken (headers: IncomingHttpHeaders): Token | undefined {
|
export function extractToken (headers: IncomingHttpHeaders): Token | undefined {
|
||||||
try {
|
try {
|
||||||
const token = extractCookieToken(headers.cookie) ?? extractAuthorizationToken(headers.authorization)
|
const token = extractAuthorizationToken(headers.authorization) ?? extractCookieToken(headers.cookie)
|
||||||
|
|
||||||
return token ?? undefined
|
return token ?? undefined
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -80,9 +80,9 @@ const extractQueryToken = (queryParams: any): string | null => {
|
|||||||
const extractToken = (headers: IncomingHttpHeaders, queryParams: any): string => {
|
const extractToken = (headers: IncomingHttpHeaders, queryParams: any): string => {
|
||||||
try {
|
try {
|
||||||
const token =
|
const token =
|
||||||
extractCookieToken(headers.cookie) ??
|
|
||||||
extractAuthorizationToken(headers.authorization) ??
|
extractAuthorizationToken(headers.authorization) ??
|
||||||
extractQueryToken(queryParams)
|
extractQueryToken(queryParams) ??
|
||||||
|
extractCookieToken(headers.cookie)
|
||||||
|
|
||||||
if (token === null) {
|
if (token === null) {
|
||||||
throw new ApiError(401)
|
throw new ApiError(401)
|
||||||
|
@ -51,9 +51,9 @@ const extractRawQueryToken = (queryParams: any): string | null => {
|
|||||||
export const extractToken = (headers: IncomingHttpHeaders, queryParams: any): { token: Token, rawToken: string } => {
|
export const extractToken = (headers: IncomingHttpHeaders, queryParams: any): { token: Token, rawToken: string } => {
|
||||||
try {
|
try {
|
||||||
const rawToken =
|
const rawToken =
|
||||||
extractRawCookieToken(headers.cookie) ??
|
|
||||||
extractRawAuthorizationToken(headers.authorization) ??
|
extractRawAuthorizationToken(headers.authorization) ??
|
||||||
extractRawQueryToken(queryParams)
|
extractRawQueryToken(queryParams) ??
|
||||||
|
extractRawCookieToken(headers.cookie)
|
||||||
|
|
||||||
if (rawToken === null) {
|
if (rawToken === null) {
|
||||||
throw new ApiError(401)
|
throw new ApiError(401)
|
||||||
|
Loading…
Reference in New Issue
Block a user