@@ -265,8 +265,7 @@ export class UserProfileService {
265265 const base64Credentials = authHeader . trim ( ) . substring ( 'basic ' . length ) ;
266266 const [ username , password ] = Buffer . from ( base64Credentials , 'base64' ) . toString ( ) . split ( ':' ) ;
267267 if ( ! username || ! password ) {
268- this . logger . debug ( `Basic credentials are malformed, cannot extract username and password.` ) ;
269- return undefined ;
268+ throw new Error ( `Malformed basic credentials in Authorization header.` ) ;
270269 }
271270
272271 const activatedProfile = await this . activate ( clusterClient , {
@@ -338,16 +337,15 @@ export class UserProfileService {
338337 { request, dataPath } : UserProfileGetCurrentParams
339338 ) {
340339 if ( request . auth . isAuthenticated === false ) {
341- this . logger . debug ( `Request to get current user profile is not authenticated.` ) ;
342- return null ;
340+ throw new Error ( 'Request to get current user profile is not authenticated.' ) ;
343341 }
344342
345343 let profileId : string | undefined ;
346344 let sessionId : string | undefined ;
347345 let profileActivationRequired : boolean | undefined ;
348346 let apiKeyRetrievalRequired : boolean | undefined ;
349347
350- if ( request . headers . cookie ) {
348+ if ( await session . getSID ( request ) ) {
351349 this . logger . debug ( `Request to get current user profile is authenticated via session.` ) ;
352350 ( { profileId, sessionId } = await this . getCurrentUserProfileIdViaSession ( session , request ) ) ;
353351 } else {
0 commit comments